change a few // comments back to /* */ for older compilers
This commit is contained in:
parent
dbca5e9d5a
commit
ec3d2bfe6c
@ -1,8 +1,13 @@
|
|||||||
#ifndef LIBOWFAT_ATTRIBUTES_H
|
#ifndef LIBOWFAT_ATTRIBUTES_H
|
||||||
#define LIBOWFAT_ATTRIBUTES_H
|
#define LIBOWFAT_ATTRIBUTES_H
|
||||||
|
|
||||||
|
|
||||||
|
#if __GNUC__ && (__STDC_VERSION__ < 199901L)
|
||||||
|
#define inline __inline__
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#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 __attribute__(x)
|
||||||
#define __extension__
|
#define __extension__
|
||||||
#endif
|
#endif
|
||||||
|
21
ent.c
21
ent.c
@ -1,3 +1,4 @@
|
|||||||
|
#define _BSD_SOURCE
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -26,7 +27,7 @@ struct entity {
|
|||||||
struct letter {
|
struct letter {
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
struct letters* weiter;
|
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 {
|
struct letters {
|
||||||
@ -98,19 +99,19 @@ void marshalhelper(struct letters* s) {
|
|||||||
if (!s) return;
|
if (!s) return;
|
||||||
used+=s->n;
|
used+=s->n;
|
||||||
assert(used<nodes+2);
|
assert(used<nodes+2);
|
||||||
for (i=1; i!=0; ++i) { // start at 1, go to 256, then access modulo 256; effect: sort but put 0 last
|
for (i=1; i!=0; ++i) { /* start at 1, go to 256, then access modulo 256; effect: sort but put 0 last */
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
i&=0xff;
|
i&=0xff;
|
||||||
// printf("%c ",i);
|
/* printf("%c ",i); */
|
||||||
if (s->liste[i].c!=i) {
|
if (s->liste[i].c!=i) {
|
||||||
if (i==0) return;
|
if (i==0) return;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// printf("marshalhelper: %c\n",i);
|
/* printf("marshalhelper: %c\n",i); */
|
||||||
x=(unsigned char)s->liste[i].c;
|
x=(unsigned char)s->liste[i].c;
|
||||||
if (!x) {
|
if (!x) {
|
||||||
size_t l=strlen((char*)s->liste[i].weiter)+1;
|
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;
|
x|=useddata<<8;
|
||||||
assert(useddata+l<=datasize);
|
assert(useddata+l<=datasize);
|
||||||
memcpy(data+useddata,s->liste[i].weiter,l);
|
memcpy(data+useddata,s->liste[i].weiter,l);
|
||||||
@ -123,7 +124,7 @@ void marshalhelper(struct letters* s) {
|
|||||||
}
|
}
|
||||||
marshaled[++myindex]=x;
|
marshaled[++myindex]=x;
|
||||||
}
|
}
|
||||||
// printf("return\n");
|
/* printf("return\n"); */
|
||||||
}
|
}
|
||||||
|
|
||||||
void marshal(struct letters* s) {
|
void marshal(struct letters* s) {
|
||||||
@ -169,13 +170,13 @@ int main() {
|
|||||||
char* s,* entity;
|
char* s,* entity;
|
||||||
size_t ul;
|
size_t ul;
|
||||||
if (!isspace(buf[0])) continue;
|
if (!isspace(buf[0])) continue;
|
||||||
for (s=buf; *s && *s!='"'; ++s) ; // skip whitespace
|
for (s=buf; *s && *s!='"'; ++s) ; /* skip whitespace */
|
||||||
if (!(*s=='"')) continue;
|
if (!(*s=='"')) continue;
|
||||||
++s;
|
++s;
|
||||||
entity=s;
|
entity=s;
|
||||||
if (*entity!='&') continue;
|
if (*entity!='&') continue;
|
||||||
++entity; ++s;
|
++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=='"')) continue;
|
||||||
if (s[-1]!=';') continue;
|
if (s[-1]!=';') continue;
|
||||||
s[-1]=0; ++s;
|
s[-1]=0; ++s;
|
||||||
@ -217,7 +218,7 @@ int main() {
|
|||||||
addword(&d,(*cur)->entity,(*cur)->utf8);
|
addword(&d,(*cur)->entity,(*cur)->utf8);
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
// dump(d,0);
|
/* dump(d,0); */
|
||||||
marshal(d);
|
marshal(d);
|
||||||
{
|
{
|
||||||
FILE* f=fopen("entities.h","w");
|
FILE* f=fopen("entities.h","w");
|
||||||
@ -235,7 +236,7 @@ int main() {
|
|||||||
fprintf(f,"\n }\n};");
|
fprintf(f,"\n }\n};");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
// puts(lookup(heap,1,"zwnj"));
|
/* puts(lookup(heap,1,"zwnj")); */
|
||||||
#if 0
|
#if 0
|
||||||
puts("};");
|
puts("};");
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +33,7 @@ simple:
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (ch>0xffff) {
|
if (ch>0xffff) {
|
||||||
if (ch>0x10ffff) return 0; // highest representable unicode codepoint
|
if (ch>0x10ffff) return 0; /* highest representable unicode codepoint */
|
||||||
if (dest) {
|
if (dest) {
|
||||||
dest[0]='\\';
|
dest[0]='\\';
|
||||||
dest[1]='u';
|
dest[1]='u';
|
||||||
|
@ -14,7 +14,7 @@ size_t fmt_httpdate(char* dest,time_t t) {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct tm tmp;
|
struct tm tmp;
|
||||||
struct tm* x=&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
|
#else
|
||||||
struct tm* x=gmtime(&t);
|
struct tm* x=gmtime(&t);
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,7 @@ size_t fmt_iso8601(char* dest,time_t t) {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct tm tmp;
|
struct tm tmp;
|
||||||
struct tm* x=&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
|
#else
|
||||||
struct tm* x=gmtime(&t);
|
struct tm* x=gmtime(&t);
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,8 +49,7 @@ size_t scan_httpdate(const char *in,time_t *t) {
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
c+=scan_ulong(c,&tmp); x.tm_mday=(int)tmp;
|
c+=scan_ulong(c,&tmp); x.tm_mday=(int)tmp;
|
||||||
while (*c==' ') ++c; // work around crappy sqlite download httpd
|
while (*c==' ') ++c; /* work around crappy sqlite download httpd */
|
||||||
// ++c;
|
|
||||||
for (i=0; i<12; ++i)
|
for (i=0; i<12; ++i)
|
||||||
if (case_equalb(c,3,months+i*3)) {
|
if (case_equalb(c,3,months+i*3)) {
|
||||||
x.tm_mon=i; break;
|
x.tm_mon=i; break;
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
* Note: *dest will point inside the input buffer!
|
* Note: *dest will point inside the input buffer!
|
||||||
*/
|
*/
|
||||||
size_t scan_netstring(const char* in,size_t len,char** dest,size_t* slen) {
|
size_t scan_netstring(const char* in,size_t len,char** dest,size_t* slen) {
|
||||||
// [len]":"[string]","
|
/* [len]":"[string]","
|
||||||
// 3:foo,3:bar,4:fini,
|
3:foo,3:bar,4:fini, */
|
||||||
unsigned long l;
|
unsigned long l;
|
||||||
size_t n=scan_ulongn(in,len,&l);
|
size_t n=scan_ulongn(in,len,&l);
|
||||||
if (!n || /* did not start with a number */
|
if (!n || /* did not start with a number */
|
||||||
|
@ -5,11 +5,11 @@ size_t scan_varint(const char* in,size_t len, unsigned long long* n) {
|
|||||||
unsigned long long l;
|
unsigned long long l;
|
||||||
if (len==0) return 0;
|
if (len==0) return 0;
|
||||||
for (l=0, i=0; i<len; ++i) {
|
for (l=0, i=0; i<len; ++i) {
|
||||||
if (i*7+7>sizeof(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;
|
return 0;
|
||||||
l+=(unsigned long long)(in[i]&0x7f) << (i*7);
|
l+=(unsigned long long)(in[i]&0x7f) << (i*7);
|
||||||
if (!(in[i]&0x80)) {
|
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;
|
*n=l;
|
||||||
return i+1;
|
return i+1;
|
||||||
}
|
}
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
#include "compiler.h"
|
||||||
static inline int foo(int bar) { return bar+1; }
|
static inline int foo(int bar) { return bar+1; }
|
||||||
|
4
uint32.h
4
uint32.h
@ -2,8 +2,8 @@
|
|||||||
#ifndef UINT32_H
|
#ifndef UINT32_H
|
||||||
#define UINT32_H
|
#define UINT32_H
|
||||||
|
|
||||||
#include <inttypes.h> // uint32_t, int32_t
|
#include <inttypes.h> /* uint32_t, int32_t */
|
||||||
#include <stddef.h> // size_t
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
4
uint64.h
4
uint64.h
@ -2,8 +2,8 @@
|
|||||||
#ifndef UINT64_H
|
#ifndef UINT64_H
|
||||||
#define UINT64_H
|
#define UINT64_H
|
||||||
|
|
||||||
#include <inttypes.h> // uint64_t, int64_t
|
#include <inttypes.h> /* uint64_t, int64_t */
|
||||||
#include <stddef.h> // size_t
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user