Deleted Added
full compact
devd.cc (247761) devd.cc (247762)
1/*-
2 * Copyright (c) 2002-2010 M. Warner Losh.
3 * 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

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

58 */
59
60// TODO list:
61// o devd.conf and devd man pages need a lot of help:
62// - devd needs to document the unix domain socket
63// - devd.conf needs more details on the supported statements.
64
65#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2010 M. Warner Losh.
3 * 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

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

58 */
59
60// TODO list:
61// o devd.conf and devd man pages need a lot of help:
62// - devd needs to document the unix domain socket
63// - devd.conf needs more details on the supported statements.
64
65#include <sys/cdefs.h>
66__FBSDID("$FreeBSD: head/sbin/devd/devd.cc 247761 2013-03-04 02:21:26Z eadler $");
66__FBSDID("$FreeBSD: head/sbin/devd/devd.cc 247762 2013-03-04 02:21:29Z eadler $");
67
68#include <sys/param.h>
69#include <sys/socket.h>
70#include <sys/stat.h>
71#include <sys/sysctl.h>
72#include <sys/types.h>
73#include <sys/wait.h>
74#include <sys/un.h>

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

580config::expand_one(const char *&src, string &dst)
581{
582 int count;
583 string buffer;
584
585 src++;
586 // $$ -> $
587 if (*src == '$') {
67
68#include <sys/param.h>
69#include <sys/socket.h>
70#include <sys/stat.h>
71#include <sys/sysctl.h>
72#include <sys/types.h>
73#include <sys/wait.h>
74#include <sys/un.h>

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

580config::expand_one(const char *&src, string &dst)
581{
582 int count;
583 string buffer;
584
585 src++;
586 // $$ -> $
587 if (*src == '$') {
588 dst.append(src++, 1);
588 dst += *src++;
589 return;
590 }
591
592 // $(foo) -> $(foo)
593 // Not sure if I want to support this or not, so for now we just pass
594 // it through.
595 if (*src == '(') {
589 return;
590 }
591
592 // $(foo) -> $(foo)
593 // Not sure if I want to support this or not, so for now we just pass
594 // it through.
595 if (*src == '(') {
596 dst.append("$");
596 dst += '$';
597 count = 1;
598 /* If the string ends before ) is matched , return. */
599 while (count > 0 && *src) {
600 if (*src == ')')
601 count--;
602 else if (*src == '(')
603 count++;
597 count = 1;
598 /* If the string ends before ) is matched , return. */
599 while (count > 0 && *src) {
600 if (*src == ')')
601 count--;
602 else if (*src == '(')
603 count++;
604 dst.append(src++, 1);
604 dst += *src++;
605 }
606 return;
607 }
608
609 // ${^A-Za-z] -> $\1
610 if (!isalpha(*src)) {
605 }
606 return;
607 }
608
609 // ${^A-Za-z] -> $\1
610 if (!isalpha(*src)) {
611 dst.append("$");
612 dst.append(src++, 1);
611 dst += '$';
612 dst += *src++;
613 return;
614 }
615
616 // $var -> replace with value
617 do {
613 return;
614 }
615
616 // $var -> replace with value
617 do {
618 buffer.append(src++, 1);
618 buffer += *src++;
619 } while (is_id_char(*src));
620 dst.append(get_variable(buffer));
621}
622
623const string
624config::expand_string(const char *src, const char *prepend, const char *append)
625{
626 const char *var_at;

--- 521 unchanged lines hidden ---
619 } while (is_id_char(*src));
620 dst.append(get_variable(buffer));
621}
622
623const string
624config::expand_string(const char *src, const char *prepend, const char *append)
625{
626 const char *var_at;

--- 521 unchanged lines hidden ---