summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/misc.c b/misc.c
index 3e62320ab..1198e70ca 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.128 2018/06/06 18:29:18 markus Exp $ */ 1/* $OpenBSD: misc.c,v 1.129 2018/06/09 03:01:12 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -239,8 +239,8 @@ set_rdomain(int fd, const char *name)
239#define QUOTE "\"" 239#define QUOTE "\""
240 240
241/* return next token in configuration line */ 241/* return next token in configuration line */
242char * 242static char *
243strdelim(char **s) 243strdelim_internal(char **s, int split_equals)
244{ 244{
245 char *old; 245 char *old;
246 int wspace = 0; 246 int wspace = 0;
@@ -250,7 +250,8 @@ strdelim(char **s)
250 250
251 old = *s; 251 old = *s;
252 252
253 *s = strpbrk(*s, WHITESPACE QUOTE "="); 253 *s = strpbrk(*s,
254 split_equals ? WHITESPACE QUOTE "=" : WHITESPACE QUOTE);
254 if (*s == NULL) 255 if (*s == NULL)
255 return (old); 256 return (old);
256 257
@@ -267,18 +268,37 @@ strdelim(char **s)
267 } 268 }
268 269
269 /* Allow only one '=' to be skipped */ 270 /* Allow only one '=' to be skipped */
270 if (*s[0] == '=') 271 if (split_equals && *s[0] == '=')
271 wspace = 1; 272 wspace = 1;
272 *s[0] = '\0'; 273 *s[0] = '\0';
273 274
274 /* Skip any extra whitespace after first token */ 275 /* Skip any extra whitespace after first token */
275 *s += strspn(*s + 1, WHITESPACE) + 1; 276 *s += strspn(*s + 1, WHITESPACE) + 1;
276 if (*s[0] == '=' && !wspace) 277 if (split_equals && *s[0] == '=' && !wspace)
277 *s += strspn(*s + 1, WHITESPACE) + 1; 278 *s += strspn(*s + 1, WHITESPACE) + 1;
278 279
279 return (old); 280 return (old);
280} 281}
281 282
283/*
284 * Return next token in configuration line; splts on whitespace or a
285 * single '=' character.
286 */
287char *
288strdelim(char **s)
289{
290 return strdelim_internal(s, 1);
291}
292
293/*
294 * Return next token in configuration line; splts on whitespace only.
295 */
296char *
297strdelimw(char **s)
298{
299 return strdelim_internal(s, 0);
300}
301
282struct passwd * 302struct passwd *
283pwcopy(struct passwd *pw) 303pwcopy(struct passwd *pw)
284{ 304{