Fossil SCM
Coding style and compiler warning fixes.
Commit
4b17cb66e852d2992ba175f21965ca03a1c17386
Parent
a0d01050a1d415e…
1 file changed
+13
-28
+13
-28
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -143,90 +143,75 @@ | ||
| 143 | 143 | fossil_print("%s", blob_str(&g.thLog)); |
| 144 | 144 | fossil_print("\n------------------- END TRACE LOG -------------------\n"); |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - | |
| 149 | 148 | /* |
| 150 | -** - adopted from ls_cmd_rev in checkin.c | |
| 149 | +** - adopted from ls_cmd_rev in checkin.c | |
| 151 | 150 | ** - adopted commands/error handling for usage within th1 |
| 152 | 151 | ** - interface adopted to allow result creation as TH1 List |
| 153 | 152 | ** |
| 154 | 153 | ** Takes a checkin identifier in zRev and an optiona glob pattern in zGLOB |
| 155 | 154 | ** as parameter returns a TH list in pzList,pnList with filenames matching |
| 156 | 155 | ** glob pattern with the checking |
| 157 | 156 | */ |
| 158 | 157 | static void dir_cmd_rev( |
| 159 | 158 | Th_Interp *interp, |
| 160 | - char** pzList, | |
| 161 | - int* pnList, | |
| 162 | - const char *zRev, /* Revision string given */ | |
| 163 | - const char* zGlob /* */ | |
| 159 | + char **pzList, | |
| 160 | + int *pnList, | |
| 161 | + const char *zRev, /* Revision string given */ | |
| 162 | + const char *zGlob /* Glob pattern given */ | |
| 164 | 163 | ){ |
| 165 | 164 | Stmt q; |
| 166 | 165 | char *zOrderBy = "pathname COLLATE nocase"; |
| 167 | - char *zName; | |
| 168 | 166 | int rid; |
| 169 | - int i; | |
| 170 | 167 | |
| 171 | 168 | rid = th1_name_to_typed_rid(interp, zRev, "ci"); |
| 172 | - | |
| 173 | 169 | compute_fileage(rid, zGlob); |
| 174 | 170 | db_prepare(&q, |
| 175 | 171 | "SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n" |
| 176 | 172 | " blob.size\n" |
| 177 | 173 | " FROM fileage, blob\n" |
| 178 | 174 | " WHERE blob.rid=fileage.fid \n" |
| 179 | 175 | " ORDER BY %s;", zOrderBy /*safe-for-%s*/ |
| 180 | 176 | ); |
| 181 | - | |
| 182 | 177 | while( db_step(&q)==SQLITE_ROW ){ |
| 183 | - const char *zTime = db_column_text(&q,0); | |
| 184 | - const char *zFile = db_column_text(&q,1); | |
| 185 | - int size = db_column_int(&q,2); | |
| 186 | - | |
| 178 | + const char *zFile = db_column_text(&q, 1); | |
| 187 | 179 | Th_ListAppend(interp, pzList, pnList, zFile, -1); |
| 188 | - //fossil_print("%s\n", zFile); | |
| 189 | 180 | } |
| 190 | 181 | db_finalize(&q); |
| 191 | 182 | } |
| 192 | 183 | |
| 193 | 184 | /* |
| 194 | 185 | ** TH1 command: dir CHECKIN ?GLOB? |
| 195 | 186 | ** |
| 196 | -** Returns a list containing all files in CHECKIN. If GLOB is given | |
| 197 | -** only the files matching the pattern GLOB within CHECKIN will be returned. | |
| 187 | +** Returns a list containing all files in CHECKIN. If GLOB is given only | |
| 188 | +** the files matching the pattern GLOB within CHECKIN will be returned. | |
| 198 | 189 | */ |
| 199 | 190 | static int dirCmd( |
| 200 | 191 | Th_Interp *interp, |
| 201 | 192 | void *ctx, |
| 202 | 193 | int argc, |
| 203 | 194 | const char **argv, |
| 204 | 195 | int *argl |
| 205 | 196 | ){ |
| 206 | 197 | const char *zGlob = 0; |
| 207 | - char *zList = 0; | |
| 208 | - int nList = 0; | |
| 209 | - int i; | |
| 210 | 198 | |
| 211 | - if( argc!=2 && argc != 3){ | |
| 199 | + if( argc!=2 && argc!=3 ){ | |
| 212 | 200 | return Th_WrongNumArgs(interp, "dir CHECKIN ?GLOB?"); |
| 213 | 201 | } |
| 214 | - | |
| 215 | - if( argc == 3){ | |
| 202 | + if( argc==3 ){ | |
| 216 | 203 | zGlob = argv[2]; |
| 217 | 204 | } |
| 218 | - | |
| 219 | 205 | if( Th_IsRepositoryOpen() ){ |
| 206 | + char *zList = 0; | |
| 207 | + int nList = 0; | |
| 220 | 208 | dir_cmd_rev(interp, &zList, &nList, argv[1], zGlob); |
| 221 | - | |
| 222 | 209 | Th_SetResult(interp, zList, nList); |
| 223 | 210 | Th_Free(interp, zList); |
| 224 | - | |
| 225 | 211 | return TH_OK; |
| 226 | - | |
| 227 | - } else { | |
| 212 | + }else{ | |
| 228 | 213 | Th_SetResult(interp, "repository unavailable", -1); |
| 229 | 214 | return TH_ERROR; |
| 230 | 215 | } |
| 231 | 216 | } |
| 232 | 217 | |
| 233 | 218 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -143,90 +143,75 @@ | |
| 143 | fossil_print("%s", blob_str(&g.thLog)); |
| 144 | fossil_print("\n------------------- END TRACE LOG -------------------\n"); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | |
| 149 | /* |
| 150 | ** - adopted from ls_cmd_rev in checkin.c |
| 151 | ** - adopted commands/error handling for usage within th1 |
| 152 | ** - interface adopted to allow result creation as TH1 List |
| 153 | ** |
| 154 | ** Takes a checkin identifier in zRev and an optiona glob pattern in zGLOB |
| 155 | ** as parameter returns a TH list in pzList,pnList with filenames matching |
| 156 | ** glob pattern with the checking |
| 157 | */ |
| 158 | static void dir_cmd_rev( |
| 159 | Th_Interp *interp, |
| 160 | char** pzList, |
| 161 | int* pnList, |
| 162 | const char *zRev, /* Revision string given */ |
| 163 | const char* zGlob /* */ |
| 164 | ){ |
| 165 | Stmt q; |
| 166 | char *zOrderBy = "pathname COLLATE nocase"; |
| 167 | char *zName; |
| 168 | int rid; |
| 169 | int i; |
| 170 | |
| 171 | rid = th1_name_to_typed_rid(interp, zRev, "ci"); |
| 172 | |
| 173 | compute_fileage(rid, zGlob); |
| 174 | db_prepare(&q, |
| 175 | "SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n" |
| 176 | " blob.size\n" |
| 177 | " FROM fileage, blob\n" |
| 178 | " WHERE blob.rid=fileage.fid \n" |
| 179 | " ORDER BY %s;", zOrderBy /*safe-for-%s*/ |
| 180 | ); |
| 181 | |
| 182 | while( db_step(&q)==SQLITE_ROW ){ |
| 183 | const char *zTime = db_column_text(&q,0); |
| 184 | const char *zFile = db_column_text(&q,1); |
| 185 | int size = db_column_int(&q,2); |
| 186 | |
| 187 | Th_ListAppend(interp, pzList, pnList, zFile, -1); |
| 188 | //fossil_print("%s\n", zFile); |
| 189 | } |
| 190 | db_finalize(&q); |
| 191 | } |
| 192 | |
| 193 | /* |
| 194 | ** TH1 command: dir CHECKIN ?GLOB? |
| 195 | ** |
| 196 | ** Returns a list containing all files in CHECKIN. If GLOB is given |
| 197 | ** only the files matching the pattern GLOB within CHECKIN will be returned. |
| 198 | */ |
| 199 | static int dirCmd( |
| 200 | Th_Interp *interp, |
| 201 | void *ctx, |
| 202 | int argc, |
| 203 | const char **argv, |
| 204 | int *argl |
| 205 | ){ |
| 206 | const char *zGlob = 0; |
| 207 | char *zList = 0; |
| 208 | int nList = 0; |
| 209 | int i; |
| 210 | |
| 211 | if( argc!=2 && argc != 3){ |
| 212 | return Th_WrongNumArgs(interp, "dir CHECKIN ?GLOB?"); |
| 213 | } |
| 214 | |
| 215 | if( argc == 3){ |
| 216 | zGlob = argv[2]; |
| 217 | } |
| 218 | |
| 219 | if( Th_IsRepositoryOpen() ){ |
| 220 | dir_cmd_rev(interp, &zList, &nList, argv[1], zGlob); |
| 221 | |
| 222 | Th_SetResult(interp, zList, nList); |
| 223 | Th_Free(interp, zList); |
| 224 | |
| 225 | return TH_OK; |
| 226 | |
| 227 | } else { |
| 228 | Th_SetResult(interp, "repository unavailable", -1); |
| 229 | return TH_ERROR; |
| 230 | } |
| 231 | } |
| 232 | |
| 233 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -143,90 +143,75 @@ | |
| 143 | fossil_print("%s", blob_str(&g.thLog)); |
| 144 | fossil_print("\n------------------- END TRACE LOG -------------------\n"); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | /* |
| 149 | ** - adopted from ls_cmd_rev in checkin.c |
| 150 | ** - adopted commands/error handling for usage within th1 |
| 151 | ** - interface adopted to allow result creation as TH1 List |
| 152 | ** |
| 153 | ** Takes a checkin identifier in zRev and an optiona glob pattern in zGLOB |
| 154 | ** as parameter returns a TH list in pzList,pnList with filenames matching |
| 155 | ** glob pattern with the checking |
| 156 | */ |
| 157 | static void dir_cmd_rev( |
| 158 | Th_Interp *interp, |
| 159 | char **pzList, |
| 160 | int *pnList, |
| 161 | const char *zRev, /* Revision string given */ |
| 162 | const char *zGlob /* Glob pattern given */ |
| 163 | ){ |
| 164 | Stmt q; |
| 165 | char *zOrderBy = "pathname COLLATE nocase"; |
| 166 | int rid; |
| 167 | |
| 168 | rid = th1_name_to_typed_rid(interp, zRev, "ci"); |
| 169 | compute_fileage(rid, zGlob); |
| 170 | db_prepare(&q, |
| 171 | "SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n" |
| 172 | " blob.size\n" |
| 173 | " FROM fileage, blob\n" |
| 174 | " WHERE blob.rid=fileage.fid \n" |
| 175 | " ORDER BY %s;", zOrderBy /*safe-for-%s*/ |
| 176 | ); |
| 177 | while( db_step(&q)==SQLITE_ROW ){ |
| 178 | const char *zFile = db_column_text(&q, 1); |
| 179 | Th_ListAppend(interp, pzList, pnList, zFile, -1); |
| 180 | } |
| 181 | db_finalize(&q); |
| 182 | } |
| 183 | |
| 184 | /* |
| 185 | ** TH1 command: dir CHECKIN ?GLOB? |
| 186 | ** |
| 187 | ** Returns a list containing all files in CHECKIN. If GLOB is given only |
| 188 | ** the files matching the pattern GLOB within CHECKIN will be returned. |
| 189 | */ |
| 190 | static int dirCmd( |
| 191 | Th_Interp *interp, |
| 192 | void *ctx, |
| 193 | int argc, |
| 194 | const char **argv, |
| 195 | int *argl |
| 196 | ){ |
| 197 | const char *zGlob = 0; |
| 198 | |
| 199 | if( argc!=2 && argc!=3 ){ |
| 200 | return Th_WrongNumArgs(interp, "dir CHECKIN ?GLOB?"); |
| 201 | } |
| 202 | if( argc==3 ){ |
| 203 | zGlob = argv[2]; |
| 204 | } |
| 205 | if( Th_IsRepositoryOpen() ){ |
| 206 | char *zList = 0; |
| 207 | int nList = 0; |
| 208 | dir_cmd_rev(interp, &zList, &nList, argv[1], zGlob); |
| 209 | Th_SetResult(interp, zList, nList); |
| 210 | Th_Free(interp, zList); |
| 211 | return TH_OK; |
| 212 | }else{ |
| 213 | Th_SetResult(interp, "repository unavailable", -1); |
| 214 | return TH_ERROR; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 |