summaryrefslogtreecommitdiff
path: root/appl
diff options
context:
space:
mode:
Diffstat (limited to 'appl')
-rw-r--r--appl/cmd/m4.b2
-rw-r--r--appl/lib/daytime.b43
2 files changed, 31 insertions, 14 deletions
diff --git a/appl/cmd/m4.b b/appl/cmd/m4.b
index 39558384..bc992b4f 100644
--- a/appl/cmd/m4.b
+++ b/appl/cmd/m4.b
@@ -288,7 +288,7 @@ isname(s: string): int
isalpha(c: int): int
{
- return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c > 16r80;
+ return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c > 16rA0;
}
hash(name: string): int
diff --git a/appl/lib/daytime.b b/appl/lib/daytime.b
index 0e16073b..5fc62fc4 100644
--- a/appl/lib/daytime.b
+++ b/appl/lib/daytime.b
@@ -222,21 +222,26 @@ readtimezone(fname: string): ref Timezone
tz.stdiff = 0;
tz.stname = "GMT";
- fd: ref Sys->FD;
+ s: string;
if(fname == nil){
- fd = sys->open("/env/timezone", Sys->OREAD);
- if(fd == nil)
- fd = sys->open("/locale/timezone", Sys->OREAD);
- }else
- fd = sys->open("/locale/" + fname, sys->OREAD);
- if(fd == nil)
- return tz;
- buf := array[2048] of byte;
- cnt := sys->read(fd, buf, len buf);
- if(cnt <= 0)
+ s = readfile("/env/timezone");
+ if(s == nil)
+ s = readfile("/locale/timezone");
+ }else{
+ if(fname[0] != '/' && fname[0] != '#')
+ fname = "/locale/" + fname;
+ s = readfile(fname);
+ }
+ if(s == nil)
return tz;
-
- (n, val) := sys->tokenize(string buf[0:cnt], "\t \n\r");
+ if(s[0] == '/' || s[0] == '#'){
+ if(s[len s-1] == '\n')
+ s = s[0: len s-1];
+ s = readfile(s);
+ if(s == nil)
+ return tz;
+ }
+ (n, val) := sys->tokenize(s, "\t \n\r");
if(n < 4)
return tz;
@@ -255,6 +260,18 @@ readtimezone(fname: string): ref Timezone
return tz;
}
+readfile(name: string): string
+{
+ fd := sys->open(name, Sys->OREAD);
+ if(fd == nil)
+ return nil;
+ buf := array[2048] of byte;
+ n := sys->read(fd, buf, len buf);
+ if(n <= 0)
+ return nil;
+ return string buf[0:n];
+}
+
SEC2MIN: con 60;
SEC2HOUR: con 60*SEC2MIN;
SEC2DAY: con 24*SEC2HOUR;