chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git.distorted.org.uk:~mdw/publish/public-git/disorder
[disorder]
/
lib
/
macros-builtin.c
diff --git
a/lib/macros-builtin.c
b/lib/macros-builtin.c
index 8c88f723f6a2f2ee4fab917e4a6f00490991751e..60403f010a73d3e55ca8d91cee69779631c62e5c 100644
(file)
--- a/
lib/macros-builtin.c
+++ b/
lib/macros-builtin.c
@@
-38,12
+38,12
@@
#include <fcntl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/stat.h>
+#include "log.h"
#include "hash.h"
#include "mem.h"
#include "macros.h"
#include "sink.h"
#include "syscalls.h"
#include "hash.h"
#include "mem.h"
#include "macros.h"
#include "sink.h"
#include "syscalls.h"
-#include "log.h"
#include "wstat.h"
#include "kvp.h"
#include "split.h"
#include "wstat.h"
#include "kvp.h"
#include "split.h"
@@
-79,7
+79,7
@@
char *mx_find(const char *name, int report) {
if(name[0] == '/') {
if(access(name, O_RDONLY) < 0) {
if(report)
if(name[0] == '/') {
if(access(name, O_RDONLY) < 0) {
if(report)
- error(errno, "cannot read %s", name);
+
disorder_
error(errno, "cannot read %s", name);
return 0;
}
path = xstrdup(name);
return 0;
}
path = xstrdup(name);
@@
-92,14
+92,14
@@
char *mx_find(const char *name, int report) {
}
if(n >= include_path.nvec) {
if(report)
}
if(n >= include_path.nvec) {
if(report)
- error(0, "cannot find '%s' in search path", name);
+
disorder_
error(0, "cannot find '%s' in search path", name);
return 0;
}
}
return path;
}
return 0;
}
}
return path;
}
-/*$ @include{TEMPLATE}
@
+/*$ @include{TEMPLATE}
*
* Includes TEMPLATE.
*
*
* Includes TEMPLATE.
*
@@
-137,11
+137,11
@@
static int exp_include(int attribute((unused)) nargs,
/* Read the raw file. As with mx_expand_file() we insist that the file is a
* regular file. */
if((fd = open(path, O_RDONLY)) < 0)
/* Read the raw file. As with mx_expand_file() we insist that the file is a
* regular file. */
if((fd = open(path, O_RDONLY)) < 0)
- fatal(errno, "error opening %s", path);
+
disorder_
fatal(errno, "error opening %s", path);
if(fstat(fd, &sb) < 0)
if(fstat(fd, &sb) < 0)
- fatal(errno, "error statting %s", path);
+
disorder_
fatal(errno, "error statting %s", path);
if(!S_ISREG(sb.st_mode))
if(!S_ISREG(sb.st_mode))
- fatal(0, "%s: not a regular file", path);
+
disorder_
fatal(0, "%s: not a regular file", path);
while((n = read(fd, buffer, sizeof buffer)) > 0) {
if(sink_write(output, buffer, n) < 0) {
xclose(fd);
while((n = read(fd, buffer, sizeof buffer)) > 0) {
if(sink_write(output, buffer, n) < 0) {
xclose(fd);
@@
-149,14
+149,14
@@
static int exp_include(int attribute((unused)) nargs,
}
}
if(n < 0)
}
}
if(n < 0)
- fatal(errno, "error reading %s", path);
+
disorder_
fatal(errno, "error reading %s", path);
xclose(fd);
return 0;
}
xclose(fd);
return 0;
}
-/*$ @include{COMMAND}
@
+/*$ @include{COMMAND}
*
*
- * Executes COMMAND via the shell (using "sh -c") and copies its
+ * Executes COMMAND via the shell (using "sh
\
-c") and copies its
* standard output to the template output. The shell command output
* is not expanded or modified in any other way.
*
* standard output to the template output. The shell command output
* is not expanded or modified in any other way.
*
@@
-180,7
+180,7
@@
static int exp_shell(int attribute((unused)) nargs,
xdup2(p[1], 1);
xclose(p[1]);
execlp("sh", "sh", "-c", args[0], (char *)0);
xdup2(p[1], 1);
xclose(p[1]);
execlp("sh", "sh", "-c", args[0], (char *)0);
- fatal(errno, "error executing sh");
+
disorder_
fatal(errno, "error executing sh");
}
xclose(p[1]);
while((n = read(p[0], buffer, sizeof buffer))) {
}
xclose(p[1]);
while((n = read(p[0], buffer, sizeof buffer))) {
@@
-188,7
+188,7
@@
static int exp_shell(int attribute((unused)) nargs,
if(errno == EINTR)
continue;
else
if(errno == EINTR)
continue;
else
- fatal(errno, "error reading from pipe");
+
disorder_
fatal(errno, "error reading from pipe");
}
if(output->write(output, buffer, n) < 0)
return -1;
}
if(output->write(output, buffer, n) < 0)
return -1;
@@
-197,13
+197,13
@@
static int exp_shell(int attribute((unused)) nargs,
while((n = waitpid(pid, &w, 0)) < 0 && errno == EINTR)
;
if(n < 0)
while((n = waitpid(pid, &w, 0)) < 0 && errno == EINTR)
;
if(n < 0)
- fatal(errno, "error calling waitpid");
+
disorder_
fatal(errno, "error calling waitpid");
if(w)
if(w)
- error(0, "shell command '%s' %s", args[0], wstat(w));
+
disorder_
error(0, "shell command '%s' %s", args[0], wstat(w));
return 0;
}
return 0;
}
-/*$ @if{CONDITION}{IF-TRUE}{IF-FALSE}
@
+/*$ @if{CONDITION}{IF-TRUE}{IF-FALSE}
*
* If CONDITION is "true" then evaluates to IF-TRUE. Otherwise
* evaluates to IF-FALSE. The IF-FALSE part is optional.
*
* If CONDITION is "true" then evaluates to IF-TRUE. Otherwise
* evaluates to IF-FALSE. The IF-FALSE part is optional.
@@
-225,7
+225,7
@@
static int exp_if(int nargs,
return 0;
}
return 0;
}
-/*$ @and{BRANCH}{BRANCH}...
@
+/*$ @and{BRANCH}{BRANCH}...
*
* Expands to "true" if all the branches are "true" otherwise to "false". If
* there are no brances then the result is "true". Only as many branches as
*
* Expands to "true" if all the branches are "true" otherwise to "false". If
* there are no brances then the result is "true". Only as many branches as
@@
-251,7
+251,7
@@
static int exp_and(int nargs,
return mx_bool_result(output, result);
}
return mx_bool_result(output, result);
}
-/*$ @or{BRANCH}{BRANCH}...
@
+/*$ @or{BRANCH}{BRANCH}...
*
* Expands to "true" if any of the branches are "true" otherwise to "false".
* If there are no brances then the result is "false". Only as many branches
*
* Expands to "true" if any of the branches are "true" otherwise to "false".
* If there are no brances then the result is "false". Only as many branches
@@
-277,7
+277,7
@@
static int exp_or(int nargs,
return mx_bool_result(output, result);
}
return mx_bool_result(output, result);
}
-/*$ @not{CONDITION}
@
+/*$ @not{CONDITION}
*
* Expands to "true" unless CONDITION is "true" in which case "false".
*/
*
* Expands to "true" unless CONDITION is "true" in which case "false".
*/
@@
-288,7
+288,7
@@
static int exp_not(int attribute((unused)) nargs,
return mx_bool_result(output, !mx_str2bool(args[0]));
}
return mx_bool_result(output, !mx_str2bool(args[0]));
}
-/*$ @#{...}
@
+/*$ @#{...}
*
* Expands to nothing. The argument(s) are not fully evaluated, and no side
* effects occur.
*
* Expands to nothing. The argument(s) are not fully evaluated, and no side
* effects occur.
@@
-300,7
+300,7
@@
static int exp_comment(int attribute((unused)) nargs,
return 0;
}
return 0;
}
-/*$ @urlquote{STRING}
@
+/*$ @urlquote{STRING}
*
* URL-quotes a string, i.e. replaces any characters not safe to use unquoted
* in a URL with %-encoded form.
*
* URL-quotes a string, i.e. replaces any characters not safe to use unquoted
* in a URL with %-encoded form.
@@
-315,7
+315,7
@@
static int exp_urlquote(int attribute((unused)) nargs,
return 0;
}
return 0;
}
-/*$ @eq{S1}{S2}...
@
+/*$ @eq{S1}{S2}...
*
* Expands to "true" if all the arguments are identical, otherwise to "false"
* (i.e. if any pair of arguments differs).
*
* Expands to "true" if all the arguments are identical, otherwise to "false"
* (i.e. if any pair of arguments differs).
@@
-339,7
+339,7
@@
static int exp_eq(int nargs,
return mx_bool_result(output, result);
}
return mx_bool_result(output, result);
}
-/*$ @ne{S1}{S2}...
@
+/*$ @ne{S1}{S2}...
*
* Expands to "true" if all of the arguments differ from one another, otherwise
* to "false" (i.e. if any value appears more than once).
*
* Expands to "true" if all of the arguments differ from one another, otherwise
* to "false" (i.e. if any value appears more than once).
@@
-363,7
+363,7
@@
static int exp_ne(int nargs,
return mx_bool_result(output, result);
}
return mx_bool_result(output, result);
}
-/*$ @discard{...}
@
+/*$ @discard{...}
*
* Expands to nothing. Unlike the comment expansion @#{...}, side effects of
* arguments are not suppressed. So this can be used to surround a collection
*
* Expands to nothing. Unlike the comment expansion @#{...}, side effects of
* arguments are not suppressed. So this can be used to surround a collection
@@
-376,7
+376,7
@@
static int exp_discard(int attribute((unused)) nargs,
return 0;
}
return 0;
}
-/*$ @define{NAME}{ARG1 ARG2...}{DEFINITION}
@
+/*$ @define{NAME}{ARG1 ARG2...}{DEFINITION}
*
* Define a macro. The macro will be called NAME and will act like an
* expansion. When it is expanded, the expansion is replaced by DEFINITION,
*
* Define a macro. The macro will be called NAME and will act like an
* expansion. When it is expanded, the expansion is replaced by DEFINITION,