strgen/strgen.c
changeset 4461 e46bbe947a06
parent 4447 d196eec23f9f
child 4464 281a2984a0c9
equal deleted inserted replaced
4460:de71777a1e9b 4461:e46bbe947a06
  1241 #endif
  1241 #endif
  1242 
  1242 
  1243 int CDECL main(int argc, char* argv[])
  1243 int CDECL main(int argc, char* argv[])
  1244 {
  1244 {
  1245 	char pathbuf[256];
  1245 	char pathbuf[256];
  1246 	const char *src_dir, *dest_dir;
  1246 	const char *src_dir = ".";
       
  1247 	const char *dest_dir = NULL;
  1247 
  1248 
  1248 	int show_todo = 0;
  1249 	int show_todo = 0;
  1249 
  1250 
  1250 	if (argc > 1 && (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0)) {
  1251 	while (argc > 1 && *argv[1] == '-') {
  1251 		puts("$Revision$");
  1252 		if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) {
  1252 		return 0;
  1253 			puts("$Revision$");
  1253 	}
  1254 			return 0;
  1254 
  1255 		}
  1255 	if (argc > 1 && (strcmp(argv[1], "-t") == 0 || strcmp(argv[1], "--todo") == 0)) {
  1256 
  1256 		show_todo = 1;
  1257 		if (strcmp(argv[1], "-t") == 0 || strcmp(argv[1], "--todo") == 0) {
  1257 		argc--, argv++;
  1258 			show_todo = 1;
  1258 	}
  1259 			argc--, argv++;
  1259 
  1260 			continue;
  1260 	if (argc > 1 && (strcmp(argv[1], "-w") == 0 || strcmp(argv[1], "--warning") == 0)) {
  1261 		}
  1261 		show_todo = 2;
  1262 
  1262 		argc--, argv++;
  1263 		if (strcmp(argv[1], "-w") == 0 || strcmp(argv[1], "--warning") == 0) {
  1263 	}
  1264 			show_todo = 2;
  1264 
  1265 			argc--, argv++;
  1265 	if (argc > 1 && (
  1266 			continue;
  1266 				strcmp(argv[1], "-h") == 0 ||
  1267 		}
  1267 				strcmp(argv[1], "--help") == 0 ||
  1268 
  1268 				strcmp(argv[1], "-?") == 0
  1269 		if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) {
  1269 			)) {
  1270 			puts(
  1270 		puts(
  1271 				"strgen - $Revision$\n"
  1271 			"strgen - $Revision$\n"
  1272 				" -v | --version    print version information and exit\n"
  1272 			" -v | --version    print version information and exit\n"
  1273 				" -t | --todo       replace any untranslated strings with '<TODO>'\n"
  1273 			" -t | --todo       replace any untranslated strings with '<TODO>'\n"
  1274 				" -w | --warning    print a warning for any untranslated strings\n"
  1274 			" -w | --warning    print a warning for any untranslated strings\n"
  1275 				" -h | -? | --help  print this help message and exit\n"
  1275 			" -h | -? | --help  print this help message and exit\n"
  1276 				" -s | --source_dir search for english.txt in the specified directory\n"
  1276 			" -s | --source_dir search for english.txt in the specified directory\n"
  1277 				" -d | --dest_dir   put output file in the specified directory, create if needed\n"
  1277 			" -d | --dest_dir   put output file in the specified directory, create if needed\n"
  1278 				" Run without parameters and strgen will search for english.txt and parse it,\n"
  1278 			" Run without parameters and strgen will search for english.txt and parse it,\n"
  1279 				" creating strings.h. Passing an argument, strgen will translate that language\n"
  1279 			" creating strings.h. Passing an argument, strgen will translate that language\n"
  1280 				" file using english.txt as a reference and output <language>.lng."
  1280 			" file using english.txt as a reference and output <language>.lng."
  1281 			);
  1281 		);
  1282 			return 0;
  1282 		return 0;
  1283 		}
  1283 	}
  1284 
  1284 
  1285 		if (argc > 2 && (strcmp(argv[1], "-s") == 0 || strcmp(argv[1], "--source_dir") == 0)) {
  1285 	src_dir = dest_dir = ".";
  1286 			src_dir = replace_pathsep(argv[2]);
  1286 	if (argc > 2 && (strcmp(argv[1], "-s") == 0 || strcmp(argv[1], "--source_dir") == 0)) {
  1287 			argc -= 2, argv += 2;
  1287 		src_dir = dest_dir = replace_pathsep(argv[2]); // if dest_dir is not specified, it equals src_dir
  1288 		}
  1288 		argc -= 2, argv += 2;
  1289 
  1289 	}
  1290 		if (argc > 2 && (strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "--dest_dir") == 0)) {
  1290 
  1291 			dest_dir = replace_pathsep(argv[2]);
  1291 	if (argc > 2 && (strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "--dest_dir") == 0)) {
  1292 			argc -= 2, argv += 2;
  1292 		dest_dir = replace_pathsep(argv[2]);
  1293 		}
  1293 		argc -= 2, argv += 2;
  1294 	}
  1294 	}
  1295 
       
  1296 	if (dest_dir == NULL) dest_dir = src_dir; // if dest_dir is not specified, it equals src_dir
  1295 
  1297 
  1296 	/* strgen has two modes of operation. If no (free) arguments are passed
  1298 	/* strgen has two modes of operation. If no (free) arguments are passed
  1297 	 * strgen generates strings.h to the destination directory. If it is supplied
  1299 	 * strgen generates strings.h to the destination directory. If it is supplied
  1298 	 * with a (free) parameter the program will translate that language to destination
  1300 	 * with a (free) parameter the program will translate that language to destination
  1299 	 * directory. As input english.txt is parsed from the source directory */
  1301 	 * directory. As input english.txt is parsed from the source directory */