Ignore:
Timestamp:
Mar 31, 2018, 12:01:55 AM (7 years ago)
Author:
bird
Message:

kmk_ln, kmk_mkdir, kmk_mv, kmk_printf: changed to use getopt_r and got rid of remaining static buffers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/mkdir.c

    r3192 r3215  
    4242#endif
    4343
     44#define FAKES_NO_GETOPT_H /* bird */
    4445#include "config.h"
    4546#include <sys/types.h>
     
    6162# include <alloca.h>
    6263#endif
    63 #include "getopt.h"
     64#include "getopt_r.h"
    6465#ifdef __HAIKU__
    6566# include "haikufakes.h"
     
    9091kmk_builtin_mkdir(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx)
    9192{
     93        struct getopt_state_r gos;
    9294        int ch, exitval, success, pflag, vflag;
    9395        mode_t omode, *set = (mode_t *)NULL;
     
    9799        mode = NULL;
    98100
    99         /* kmk: reset getopt and set progname */
    100         opterr = 1;
    101         optarg = NULL;
    102         optopt = 0;
    103         optind = 0; /* init */
    104         while ((ch = getopt_long(argc, argv, "m:pv", long_options, NULL)) != -1)
     101        getopt_initialize_r(&gos, argc, argv, "m:pv", long_options, envp, pCtx);
     102        while ((ch = getopt_long_r(&gos, NULL)) != -1)
    105103                switch(ch) {
    106104                case 'm':
    107                         mode = optarg;
     105                        mode = gos.optarg;
    108106                        break;
    109107                case 'p':
     
    123121                }
    124122
    125         argc -= optind;
    126         argv += optind;
     123        argc -= gos.optind;
     124        argv += gos.optind;
    127125        if (argv[0] == NULL)
    128126                return usage(pCtx, 1);
Note: See TracChangeset for help on using the changeset viewer.