mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Start allowing spaces in month and day names (convert to _ on -p output)
This commit is contained in:
@@ -232,12 +232,17 @@ sub parse_input
|
||||
chomp($line);
|
||||
($Month, $Year, $Numdays, $Firstwkday, $Mondayfirst) = split(' ', $line);
|
||||
|
||||
$Month =~ s/_/ /g;
|
||||
# Day names
|
||||
$line = <STDIN>;
|
||||
return 0 unless $line;
|
||||
chomp($line);
|
||||
@Daynames = split(' ', $line);
|
||||
|
||||
for (my $i=0; $i<7; $i++) {
|
||||
$Daynames[$i] =~ s/_/ /g;
|
||||
}
|
||||
|
||||
# Prevmon prevlen
|
||||
$line = <STDIN>;
|
||||
return 0 unless $line;
|
||||
|
||||
@@ -120,6 +120,7 @@ sub read_one_month
|
||||
# Month Year Days FirstWkday MondayFirst
|
||||
if ($line =~ /^(\S+) (\d+) (\d+) (\d+) (\d+)/) {
|
||||
$self->{monthname} = $1;
|
||||
$self->{monthname} =~ s/_/ /g;
|
||||
$self->{year} = $2;
|
||||
$self->{daysinmonth} = $3;
|
||||
$self->{firstwkday} = $4;
|
||||
@@ -132,7 +133,7 @@ sub read_one_month
|
||||
$line = $in->getline();
|
||||
chomp($line);
|
||||
if ($line =~ /^\S+ \S+ \S+ \S+ \S+ \S+ \S+$/) {
|
||||
@{$self->{daynames}} = split(/ /, $line);
|
||||
@{$self->{daynames}} = map { s/_/ /g; $_; } (split(/ /, $line));
|
||||
} else {
|
||||
return (undef, "Cannot interpret line: $line");
|
||||
}
|
||||
|
||||
@@ -964,9 +964,14 @@ proc FillCalWindow {} {
|
||||
gets $file line
|
||||
regexp {^([^ ]*) ([0-9][0-9][0-9][0-9]) ([0-9][0-9]?) ([0-9]) ([0-9])} $line dummy monthName year daysInMonth firstWkday mondayFirst
|
||||
|
||||
set monthName [regsub -all {_} $monthName " "]
|
||||
# Get the day names
|
||||
gets $file line
|
||||
set DayNames $line
|
||||
set DayNames {}
|
||||
foreach day $line {
|
||||
set day [regsub -all {_} $day " "];
|
||||
lappend DayNames $day
|
||||
}
|
||||
|
||||
ConfigureCalWindow $monthName $year $firstWkday $daysInMonth
|
||||
|
||||
|
||||
17
src/rem2ps.c
17
src/rem2ps.c
@@ -383,6 +383,7 @@ void DoPsCal(void)
|
||||
int firstcol;
|
||||
DynamicBuffer buf;
|
||||
CalEntry *c, *d, *p;
|
||||
char *s;
|
||||
|
||||
/* Read the month and year name, followed by # days in month and 1st day of
|
||||
month */
|
||||
@@ -391,12 +392,28 @@ void DoPsCal(void)
|
||||
sscanf(DBufValue(&buf), "%s %s %d %d %d", month, year, &days, &wkday,
|
||||
&MondayFirst);
|
||||
|
||||
/* Replace underscores in month name with spaces */
|
||||
s = month;
|
||||
while(*s) {
|
||||
if (*s == '_') *s = ' ';
|
||||
s++;
|
||||
}
|
||||
|
||||
/* Get day names */
|
||||
DBufGets(&buf, stdin);
|
||||
sscanf(DBufValue(&buf), "%32s %32s %32s %32s %32s %32s %32s",
|
||||
DayName[0], DayName[1], DayName[2], DayName[3],
|
||||
DayName[4], DayName[5], DayName[6]);
|
||||
|
||||
/* Replace underscores in day names with spaces */
|
||||
for (i=0; i<7; i++) {
|
||||
s = DayName[i];
|
||||
while(*s) {
|
||||
if (*s == '_') *s = ' ';
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
/* We write the prolog here because it's only at this point that
|
||||
MondayFirst is set correctly. */
|
||||
if (validfile == 1) {
|
||||
|
||||
Reference in New Issue
Block a user