Deleted Added
full compact
getmntopts.c (1559) getmntopts.c (3202)
1/*-
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 39 unchanged lines hidden (view full) ---

48
49void
50getmntopts(options, m0, flagp)
51 const char *options;
52 const struct mntopt *m0;
53 int *flagp;
54{
55 const struct mntopt *m;
1/*-
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 39 unchanged lines hidden (view full) ---

48
49void
50getmntopts(options, m0, flagp)
51 const char *options;
52 const struct mntopt *m0;
53 int *flagp;
54{
55 const struct mntopt *m;
56 int negative;
56 int negative, len;
57 char *opt, *optbuf;
58
59 /* Copy option string, since it is about to be torn asunder... */
60 if ((optbuf = strdup(options)) == NULL)
61 err(1, NULL);
62
63 for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
64 /* Check for "no" prefix. */
65 if (opt[0] == 'n' && opt[1] == 'o') {
66 negative = 1;
67 opt += 2;
68 } else
69 negative = 0;
70
71 /* Scan option table. */
57 char *opt, *optbuf;
58
59 /* Copy option string, since it is about to be torn asunder... */
60 if ((optbuf = strdup(options)) == NULL)
61 err(1, NULL);
62
63 for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
64 /* Check for "no" prefix. */
65 if (opt[0] == 'n' && opt[1] == 'o') {
66 negative = 1;
67 opt += 2;
68 } else
69 negative = 0;
70
71 /* Scan option table. */
72 for (m = m0; m->m_option != NULL; ++m)
73 if (strcasecmp(opt, m->m_option) == 0)
72 for (m = m0; m->m_option != NULL; ++m) {
73 len = strlen(m->m_option);
74 if (strncasecmp(opt, m->m_option, len) == 0)
75 if ( m->m_option[len] == '\0'
76 || m->m_option[len] == '='
77 )
74 break;
78 break;
79 }
75
76 /* Save flag, or fail if option is not recognised. */
77 if (m->m_option) {
78 if (negative == m->m_inverse)
79 *flagp |= m->m_flag;
80 else
81 *flagp &= ~m->m_flag;
82 } else
83 errx(1, "-o %s: option not supported", opt);
84 }
85
86 free(optbuf);
87}
80
81 /* Save flag, or fail if option is not recognised. */
82 if (m->m_option) {
83 if (negative == m->m_inverse)
84 *flagp |= m->m_flag;
85 else
86 *flagp &= ~m->m_flag;
87 } else
88 errx(1, "-o %s: option not supported", opt);
89 }
90
91 free(optbuf);
92}