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/ln.c

    r3192 r3215  
    4242#endif /* no $id */
    4343
     44#define FAKES_NO_GETOPT_H /* bird */
    4445#include "config.h"
    4546#ifndef _MSC_VER
     
    5556#include <string.h>
    5657#include <unistd.h>
    57 #include "getopt.h"
     58#include "getopt_r.h"
    5859#ifdef _MSC_VER
    5960# include "mscfakes.h"
     
    9394{
    9495        LNINSTANCE This;
     96        struct getopt_state_r gos;
    9597        struct stat sb;
    9698        char *sourcedir;
     
    107109        This.linkf = NULL;
    108110
    109         /* kmk: reset getopt() and set program name. */
    110         opterr = 1;
    111         optarg = NULL;
    112         optopt = 0;
    113         optind = 0; /* init */
    114 
    115         while ((ch = getopt_long(argc, argv, "fhinsv", long_options, NULL)) != -1)
     111        getopt_initialize_r(&gos, argc, argv, "fhinsv", long_options, envp, pCtx);
     112        while ((ch = getopt_long_r(&gos, NULL)) != -1)
    116113                switch (ch) {
    117114                case 'f':
     
    143140                }
    144141
    145         argv += optind;
    146         argc -= optind;
     142        argv += gos.optind;
     143        argc -= gos.optind;
    147144
    148145        This.linkf = This.sflag ? symlink : link;
Note: See TracChangeset for help on using the changeset viewer.