Changeset 3217 in kBuild for trunk/src/kmk
- Timestamp:
- Mar 30, 2018 10:11:15 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/cmp.c
r3192 r3217 35 35 __RCSID("$NetBSD: cmp.c,v 1.15 2006/01/19 20:44:57 garbled Exp $"); */ 36 36 37 /********************************************************************************************************************************* 38 * Header Files * 39 *********************************************************************************************************************************/ 40 #define FAKES_NO_GETOPT_H /* bird */ 37 41 #ifdef _MSC_VER 38 42 # define MSC_DO_64_BIT_IO /* for correct off_t */ … … 51 55 # include "mscfakes.h" 52 56 #endif 53 #include "getopt .h"57 #include "getopt_r.h" 54 58 #include "kmkbuiltin.h" 55 59 #include "cmp_extern.h" 56 60 57 61 62 /********************************************************************************************************************************* 63 * Global Variables * 64 *********************************************************************************************************************************/ 58 65 static const struct option long_options[] = 59 66 { … … 69 76 kmk_builtin_cmp(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx) 70 77 { 78 struct getopt_state_r gos; 71 79 off_t skip1 = 0, skip2 = 0; 72 80 int lflag = 0, sflag = 0; … … 74 82 char *file1, *file2; 75 83 76 #ifdef KMK_BUILTIN_STANDALONE 77 setlocale(LC_ALL, ""); 78 #endif 79 80 /* reset getopt and set progname. */ 81 opterr = 1; 82 optarg = NULL; 83 optopt = 0; 84 optind = 0; /* init */ 85 86 while ((ch = getopt_long(argc, argv, "ls", long_options, NULL)) != -1) 84 getopt_initialize_r(&gos, argc, argv, "ls", long_options, envp, pCtx); 85 while ((ch = getopt_long_r(&gos, NULL)) != -1) 87 86 { 88 87 switch (ch) … … 104 103 } 105 104 } 106 argv += optind;107 argc -= optind;105 argv += gos.optind; 106 argc -= gos.optind; 108 107 109 108 if (argc < 2 || argc > 4) … … 148 147 { 149 148 KMKBUILTINCTX Ctx = { "kmk_cmp", NULL }; 149 setlocale(LC_ALL, ""); 150 150 return kmk_builtin_cmp(argc, argv, envp, &Ctx); 151 151 }
Note:
See TracChangeset
for help on using the changeset viewer.