diff --git a/compiler.h b/compiler.h index 2192d0e..eb77793 100644 --- a/compiler.h +++ b/compiler.h @@ -1,8 +1,13 @@ #ifndef LIBOWFAT_ATTRIBUTES_H #define LIBOWFAT_ATTRIBUTES_H + +#if __GNUC__ && (__STDC_VERSION__ < 199901L) +#define inline __inline__ +#endif + #ifndef __GNUC__ -// macro attribute declarations away if we don't have gcc or clang +/* macro attribute declarations away if we don't have gcc or clang */ #define __attribute__(x) #define __extension__ #endif diff --git a/ent.c b/ent.c index e044076..81e76f0 100644 --- a/ent.c +++ b/ent.c @@ -1,3 +1,4 @@ +#define _BSD_SOURCE #include #include #include @@ -26,7 +27,7 @@ struct entity { struct letter { unsigned char c; struct letters* weiter; - uint32_t marshaled; // lower 8 bits: char. rest: ofs from start of marshaled blob + uint32_t marshaled; /* lower 8 bits: char. rest: ofs from start of marshaled blob */ }; struct letters { @@ -98,19 +99,19 @@ void marshalhelper(struct letters* s) { if (!s) return; used+=s->n; assert(usedliste[i].c!=i) { if (i==0) return; continue; } -// printf("marshalhelper: %c\n",i); +/* printf("marshalhelper: %c\n",i); */ x=(unsigned char)s->liste[i].c; if (!x) { size_t l=strlen((char*)s->liste[i].weiter)+1; -// puts((char*)s->liste[i].weiter); +/* puts((char*)s->liste[i].weiter); */ x|=useddata<<8; assert(useddata+l<=datasize); memcpy(data+useddata,s->liste[i].weiter,l); @@ -123,7 +124,7 @@ void marshalhelper(struct letters* s) { } marshaled[++myindex]=x; } -// printf("return\n"); +/* printf("return\n"); */ } void marshal(struct letters* s) { @@ -169,13 +170,13 @@ int main() { char* s,* entity; size_t ul; if (!isspace(buf[0])) continue; - for (s=buf; *s && *s!='"'; ++s) ; // skip whitespace + for (s=buf; *s && *s!='"'; ++s) ; /* skip whitespace */ if (!(*s=='"')) continue; ++s; entity=s; if (*entity!='&') continue; ++entity; ++s; - for (; *s && *s!='"'; ++s) ; // skip to end of entity + for (; *s && *s!='"'; ++s) ; /* skip to end of entity */ if (!(*s=='"')) continue; if (s[-1]!=';') continue; s[-1]=0; ++s; @@ -217,7 +218,7 @@ int main() { addword(&d,(*cur)->entity,(*cur)->utf8); } fclose(f); -// dump(d,0); +/* dump(d,0); */ marshal(d); { FILE* f=fopen("entities.h","w"); @@ -235,7 +236,7 @@ int main() { fprintf(f,"\n }\n};"); fclose(f); } -// puts(lookup(heap,1,"zwnj")); +/* puts(lookup(heap,1,"zwnj")); */ #if 0 puts("};"); #endif diff --git a/fmt/fmt_escapecharjson.c b/fmt/fmt_escapecharjson.c index b943f89..78485f5 100644 --- a/fmt/fmt_escapecharjson.c +++ b/fmt/fmt_escapecharjson.c @@ -33,7 +33,7 @@ simple: return 2; } if (ch>0xffff) { - if (ch>0x10ffff) return 0; // highest representable unicode codepoint + if (ch>0x10ffff) return 0; /* highest representable unicode codepoint */ if (dest) { dest[0]='\\'; dest[1]='u'; diff --git a/fmt/fmt_httpdate.c b/fmt/fmt_httpdate.c index 0050dc1..89efaad 100644 --- a/fmt/fmt_httpdate.c +++ b/fmt/fmt_httpdate.c @@ -14,7 +14,7 @@ size_t fmt_httpdate(char* dest,time_t t) { #ifdef _WIN32 struct tm tmp; struct tm* x=&tmp; - gmtime_s(&tmp,&t); // can't recover from when this fails + gmtime_s(&tmp,&t); /* can't recover from when this fails */ #else struct tm* x=gmtime(&t); #endif diff --git a/fmt/fmt_iso8601.c b/fmt/fmt_iso8601.c index 6077364..d4e34b5 100644 --- a/fmt/fmt_iso8601.c +++ b/fmt/fmt_iso8601.c @@ -12,7 +12,7 @@ size_t fmt_iso8601(char* dest,time_t t) { #ifdef _WIN32 struct tm tmp; struct tm* x=&tmp; - gmtime_s(&tmp,&t); // can't recover from when this fails + gmtime_s(&tmp,&t); /* can't recover from when this fails */ #else struct tm* x=gmtime(&t); #endif diff --git a/scan/scan_httpdate.c b/scan/scan_httpdate.c index a8fcfc2..d71ff0b 100644 --- a/scan/scan_httpdate.c +++ b/scan/scan_httpdate.c @@ -49,8 +49,7 @@ size_t scan_httpdate(const char *in,time_t *t) { goto done; } c+=scan_ulong(c,&tmp); x.tm_mday=(int)tmp; - while (*c==' ') ++c; // work around crappy sqlite download httpd -// ++c; + while (*c==' ') ++c; /* work around crappy sqlite download httpd */ for (i=0; i<12; ++i) if (case_equalb(c,3,months+i*3)) { x.tm_mon=i; break; diff --git a/scan/scan_netstring.c b/scan/scan_netstring.c index 8027fde..83a688b 100644 --- a/scan/scan_netstring.c +++ b/scan/scan_netstring.c @@ -9,8 +9,8 @@ * Note: *dest will point inside the input buffer! */ size_t scan_netstring(const char* in,size_t len,char** dest,size_t* slen) { - // [len]":"[string]"," - // 3:foo,3:bar,4:fini, + /* [len]":"[string]"," + 3:foo,3:bar,4:fini, */ unsigned long l; size_t n=scan_ulongn(in,len,&l); if (!n || /* did not start with a number */ diff --git a/scan/scan_varint.c b/scan/scan_varint.c index ca78bd7..00453a8 100644 --- a/scan/scan_varint.c +++ b/scan/scan_varint.c @@ -5,11 +5,11 @@ size_t scan_varint(const char* in,size_t len, unsigned long long* n) { unsigned long long l; if (len==0) return 0; for (l=0, i=0; isizeof(l)*8) // value too large to fit in destination integer! + if (i*7+7>sizeof(l)*8) /* value too large to fit in destination integer! */ return 0; l+=(unsigned long long)(in[i]&0x7f) << (i*7); if (!(in[i]&0x80)) { - if (in[i]==0) return 0; // libowfat extension: reject non-minimal encoding + if (in[i]==0) return 0; /* libowfat extension: reject non-minimal encoding */ *n=l; return i+1; } diff --git a/tryinline.c b/tryinline.c index 94dc034..3b9316b 100644 --- a/tryinline.c +++ b/tryinline.c @@ -1 +1,2 @@ +#include "compiler.h" static inline int foo(int bar) { return bar+1; } diff --git a/uint32.h b/uint32.h index cffa72c..f9f619e 100644 --- a/uint32.h +++ b/uint32.h @@ -2,8 +2,8 @@ #ifndef UINT32_H #define UINT32_H -#include // uint32_t, int32_t -#include // size_t +#include /* uint32_t, int32_t */ +#include /* size_t */ #ifdef __cplusplus extern "C" { diff --git a/uint64.h b/uint64.h index d2cdcde..3f8d2c2 100644 --- a/uint64.h +++ b/uint64.h @@ -2,8 +2,8 @@ #ifndef UINT64_H #define UINT64_H -#include // uint64_t, int64_t -#include // size_t +#include /* uint64_t, int64_t */ +#include /* size_t */ #ifdef __cplusplus extern "C" {