);
return 0;
}
- case 'c': items_add((argitem){util_strdup(&argv[1][2]), 0}); break; /* compile */
- case 'a': items_add((argitem){util_strdup(&argv[1][2]), 1}); break; /* assemble */
- case 'i': items_add((argitem){util_strdup(&argv[1][2]), 2}); break; /* includes */
+#define param_argument(argtype) do { \
+ if (argv[1][2]) \
+ items_add((argitem){util_strdup(&argv[1][2]), argtype}); \
+ else { \
+ ++argv; --argc; \
+ if (argc <= 1) \
+ goto clean_params_usage; \
+ items_add((argitem){util_strdup(&argv[1][0]), argtype}); \
+ } \
+} while (0)
+
+ case 'c': param_argument(0); break; /* compile */
+ case 'a': param_argument(1); break; /* assemble */
+ case 'i': param_argument(2); break; /* includes */
default:
if (!strncmp(&argv[1][1], "debug" , 5)) { opts_debug = true; break; }
if (!strncmp(&argv[1][1], "memchk", 6)) { opts_memchk = true; break; }
util_meminfo();
return 0;
+clean_params_usage:
+ for (itr = 0; itr < items_elements; itr++)
+ mem_d(items_data[itr].name);
+ mem_d(items_data);
+ return usage(app);
}