Fossil SCM

Fix the mkbuiltin.c code generator so that it tolerates Windows-style backslash path separators on its arguments. This fixes the windows build that was busted by check-in [774bdc83556442c5].

drh 2018-08-06 21:19 trunk
Commit 030bf2002f64c3f30c4c49afab99fa221dda4d06b301bd467f32b24283d54844
1 file changed +7 -3
+7 -3
--- src/mkbuiltin.c
+++ src/mkbuiltin.c
@@ -60,11 +60,11 @@
6060
/*
6161
** There is an instance of the following for each file translated.
6262
*/
6363
typedef struct Resource Resource;
6464
struct Resource {
65
- const char *zName;
65
+ char *zName;
6666
int nByte;
6767
int idx;
6868
};
6969
7070
/*
@@ -147,18 +147,22 @@
147147
printf(" const unsigned char *pData;\n");
148148
printf(" int nByte;\n");
149149
printf("};\n");
150150
printf("static const BuiltinFileTable aBuiltinFiles[] = {\n");
151151
for(i=0; i<nRes; i++){
152
- const char *z = aRes[i].zName;
152
+ char *z = aRes[i].zName;
153153
if( strlen(z)>=nPrefix ) z += nPrefix;
154
- while( z[0]=='.' || z[0]=='/' ){ z++; }
154
+ while( z[0]=='.' || z[0]=='/' || z[0]=='\\' ){ z++; }
155155
aRes[i].zName = z;
156
+ while( z[0] ){
157
+ if( z[0]=='\\' ) z[0] = '/';
158
+ z++;
159
+ }
156160
}
157161
qsort(aRes, nRes, sizeof(aRes[0]), compareResource);
158162
for(i=0; i<nRes; i++){
159163
printf(" { \"%s\", bidata%d, %d },\n",
160164
aRes[i].zName, aRes[i].idx, aRes[i].nByte);
161165
}
162166
printf("};\n");
163167
return nErr;
164168
}
165169
--- src/mkbuiltin.c
+++ src/mkbuiltin.c
@@ -60,11 +60,11 @@
60 /*
61 ** There is an instance of the following for each file translated.
62 */
63 typedef struct Resource Resource;
64 struct Resource {
65 const char *zName;
66 int nByte;
67 int idx;
68 };
69
70 /*
@@ -147,18 +147,22 @@
147 printf(" const unsigned char *pData;\n");
148 printf(" int nByte;\n");
149 printf("};\n");
150 printf("static const BuiltinFileTable aBuiltinFiles[] = {\n");
151 for(i=0; i<nRes; i++){
152 const char *z = aRes[i].zName;
153 if( strlen(z)>=nPrefix ) z += nPrefix;
154 while( z[0]=='.' || z[0]=='/' ){ z++; }
155 aRes[i].zName = z;
 
 
 
 
156 }
157 qsort(aRes, nRes, sizeof(aRes[0]), compareResource);
158 for(i=0; i<nRes; i++){
159 printf(" { \"%s\", bidata%d, %d },\n",
160 aRes[i].zName, aRes[i].idx, aRes[i].nByte);
161 }
162 printf("};\n");
163 return nErr;
164 }
165
--- src/mkbuiltin.c
+++ src/mkbuiltin.c
@@ -60,11 +60,11 @@
60 /*
61 ** There is an instance of the following for each file translated.
62 */
63 typedef struct Resource Resource;
64 struct Resource {
65 char *zName;
66 int nByte;
67 int idx;
68 };
69
70 /*
@@ -147,18 +147,22 @@
147 printf(" const unsigned char *pData;\n");
148 printf(" int nByte;\n");
149 printf("};\n");
150 printf("static const BuiltinFileTable aBuiltinFiles[] = {\n");
151 for(i=0; i<nRes; i++){
152 char *z = aRes[i].zName;
153 if( strlen(z)>=nPrefix ) z += nPrefix;
154 while( z[0]=='.' || z[0]=='/' || z[0]=='\\' ){ z++; }
155 aRes[i].zName = z;
156 while( z[0] ){
157 if( z[0]=='\\' ) z[0] = '/';
158 z++;
159 }
160 }
161 qsort(aRes, nRes, sizeof(aRes[0]), compareResource);
162 for(i=0; i<nRes; i++){
163 printf(" { \"%s\", bidata%d, %d },\n",
164 aRes[i].zName, aRes[i].idx, aRes[i].nByte);
165 }
166 printf("};\n");
167 return nErr;
168 }
169

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button