X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Flibcore%2Flc_opts.c;h=08ba076b524b4e5523348224cec8bc3bc9f0903b;hb=69b99cb1537b9ef18b3767da0d362f82a52fdb76;hp=ff472c690807c3ee48bbceb420c34a2a0ee5cfd4;hpb=de1b0c8d4f653f534a38740ad7f6803d82f2762e;p=libfirm diff --git a/ir/libcore/lc_opts.c b/ir/libcore/lc_opts.c index ff472c690..08ba076b5 100644 --- a/ir/libcore/lc_opts.c +++ b/ir/libcore/lc_opts.c @@ -16,6 +16,9 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include @@ -726,7 +729,7 @@ int lc_opt_from_single_arg(const lc_opt_entry_t *root, int ret = 0; lc_opt_err_info_t err; - char *end, *buf; + char *end, *buf, *eqsign; if(n >= n_prefix && strncmp(opt_prefix, arg, n_prefix) == 0) { arg = arg + n_prefix; @@ -756,7 +759,10 @@ int lc_opt_from_single_arg(const lc_opt_entry_t *root, /* find the next delimiter (the -) and extract the string up to * there. */ - end = strchr(arg, OPT_DELIM); + end = strchr(arg, OPT_DELIM); + eqsign = strchr(arg, '='); + if (eqsign && eqsign < end) + end = NULL; while(end != NULL) { /* * Copy the part of the option into the buffer and add the @@ -772,7 +778,10 @@ int lc_opt_from_single_arg(const lc_opt_entry_t *root, /* Find the next option part delimiter. */ arg = end + 1; - end = strchr(arg, OPT_DELIM); + end = strchr(arg, OPT_DELIM); + eqsign = strchr(arg, '='); + if (eqsign && eqsign < end) + end = NULL; obstack_free(&obst, buf); } @@ -911,11 +920,19 @@ void lc_opts_init(const char *ini_name, lc_opt_entry_t *root, const char *arg_pr strncpy(home_dir_ini_file, local_ini_file, sizeof(home_dir_ini_file)); home_dir_ini_file[sizeof(home_dir_ini_file) - 1] = '\0'; #else - strcpy(path, getpwuid(getuid())->pw_dir); - strncat(path, "/", sizeof(path)); - /* .rc */ - snprintf(home_dir_ini_file, sizeof(home_dir_ini_file), ".%src", ini_name); - home_dir_ini_file[sizeof(home_dir_ini_file) - 1] = '\0'; + { + struct passwd *entry = getpwuid(getuid()); + if (entry != NULL) { + strcpy(path, entry->pw_dir); + strncat(path, "/", sizeof(path)); + /* .rc */ + snprintf(home_dir_ini_file, sizeof(home_dir_ini_file), ".%src", ini_name); + home_dir_ini_file[sizeof(home_dir_ini_file) - 1] = '\0'; + } else { + /* FIXME: some error occured */ + home_dir_ini_file[0] = '\0'; + } + } #endif strncat(path, home_dir_ini_file, sizeof(path));