Skip to content

Commit 00069b6

Browse files
committed
minor refactoring and more strings for translations
1 parent 7fa1972 commit 00069b6

File tree

6 files changed

+80
-85
lines changed

6 files changed

+80
-85
lines changed

hdisk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ void Set_Hard_Drive_Media_Parameters(int alignment)
430430
/* 0.91k - already tell the user what she has to expect size-wise */
431431
if (drive_statistics.bytes_per_sector == 512) {
432432
unsigned long roughsize;
433-
char* sizeunit = catgets(catalog, 13, 2, "kbytes");
433+
char const * sizeunit = catgets(catalog, 13, 2, "kbytes");
434434
roughsize = drive_statistics.sect_available_on_disk >> 1;
435435
if (roughsize > 9999) {
436436
roughsize += 512;

makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ CFLAGS=-wx -0 -mc -fpc -zp1
2121
OBJS=createfs.obj floppy.obj hdisk.obj main.obj &
2222
savefs.obj bcread.obj prf.obj userint.obj &
2323
driveio.obj getopt.obj init.obj recordbc.obj &
24-
uformat.obj kitten.obj
24+
uformat.obj msghlpr.obj kitten.obj
2525

2626
pack: format.exe .SYMBOLIC
2727
$(UPX) $(UPXFLAGS) $<
2828

2929
format.exe: $(OBJS)
3030
$(CLINK) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS) -fe=$@
3131

32-
.c.obj:
32+
.c.obj: kitten.h
3333
$(CC) $(CFLAGS) $*.c
3434

3535
# rm is built-in to wmake

nls/format.en

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,37 @@
377377
22,31:TWEAK: %d Sectors per cylinder, Format gap length %d!\n
378378
22,32:Floppy controller reset failed (code %x) - DDPT rejected?\n
379379
22,33:-- press ENTER to format disk (ESCAPE to abort) --\n
380-
22,34:
381-
22,35:
382-
22,36:
383-
22,37:
384-
22,38:
385-
22,39:
380+
22,34:[doublestepping]
381+
22,35:[configured type %hu]
382+
22,36: 500 kbps (HD 1xx0k)\n
383+
22,37: 300 kbps (DD 360k)\n
384+
22,38: 250 kbps (DD 720k)\n
385+
22,39:1000 kbps (ED 2880k)\n
386+
387+
# savefs.c
388+
23,0:Cannot write MIRROR MAP sector %lu - UNFORMAT spoiled!\n
389+
23,1:Not 512 bytes / sector. Cannot save UNFORMAT data.\n
390+
23,2:Not 1 or 2 FAT copies. Cannot save UNFORMAT data.\n
391+
23,3:WARNING: Number of reserved / boot sectors is %u, not 1.\n
392+
23,4:WARNING: Reserved sectors are %u but will be %u after format.\n
393+
23,5: Must be FAT32, not %s!\n
394+
23,6: NOT saving unformat info, not preserving bad cluster list.\n
395+
23,7:WARNING: FAT32 with FAT1x style extra Root Directory???\n
396+
23,8: Must be FAT32, not FAT1x!\n
397+
23,9: FAT32 Root Directory but FAT1x FAT!\n
398+
23,10: %s size but supposed to be FAT32!\n
399+
23,11: Implausible Root Directory, FAT or drive size! Bad boot sector?\n
400+
23,12: Big FAT for little data? Bad boot sector?\n
401+
23,13:Root Directory NOT in 1st cluster, NOT saving it!\n
402+
23,14: Drive looks unformatted, UNFORMAT information NOT saved.\n
403+
23,15:Number of reserved sectors differs: FOUND %lu / PLANNED %u.\n
404+
23,16:Number of FATs differs: FOUND %lu / PLANNED %hu\n
405+
406+
# savefs.c unable to save filesystem properties error message
407+
# Use as many messages as needed, 1 message per max 79 column line
408+
# message numbers do not need to match up for messages for different languages
409+
# Each message should end with a newline \n
410+
# after every 23 messages user will be prompted to press a key to continue
411+
24,0:Filesystem properties will change, cannot preserve the\n
412+
24,1:(possibly empty) old bad cluster list. Use a surface scan\n
413+
24,2:tool or FORMAT /U if you want to update the bad cluster list.\n

old_tcc.mak

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ LDLIBS=
2626
RM=command /c del
2727
OBJS1=createfs.obj floppy.obj hdisk.obj main.obj savefs.obj bcread.obj prf.obj
2828
OBJS2=userint.obj driveio.obj getopt.obj init.obj recordbc.obj uformat.obj
29-
OBJS3=kitten.obj
29+
OBJS3=msghlpr.obj kitten.obj
3030

3131
# build targets:
3232

@@ -41,40 +41,40 @@ format.exe: $(OBJS1) $(OBJS2) $(OBJS3)
4141
# .c.obj:
4242
# $(CC) $(CFLAGS) -c $*.c
4343

44-
createfs.obj:
44+
createfs.obj: kitten.h
4545
$(CC) $(CFLAGS) createfs.c
4646

47-
floppy.obj:
47+
floppy.obj: kitten.h
4848
$(CC) $(CFLAGS) floppy.c
4949

50-
hdisk.obj:
50+
hdisk.obj: kitten.h
5151
$(CC) $(CFLAGS) hdisk.c
5252

5353
main.obj: kitten.h
5454
$(CC) $(CFLAGS) main.c
5555

56-
savefs.obj:
56+
savefs.obj: kitten.h
5757
$(CC) $(CFLAGS) savefs.c
5858

5959
userint.obj: kitten.h
6060
$(CC) $(CFLAGS) userint.c
6161

62-
driveio.obj:
62+
driveio.obj: kitten.h
6363
$(CC) $(CFLAGS) driveio.c
6464

6565
getopt.obj:
6666
$(CC) $(CFLAGS) getopt.c
6767

68-
init.obj:
68+
init.obj: kitten.h
6969
$(CC) $(CFLAGS) init.c
7070

71-
recordbc.obj:
71+
recordbc.obj: kitten.h
7272
$(CC) $(CFLAGS) recordbc.c
7373

74-
uformat.obj:
74+
uformat.obj: kitten.h
7575
$(CC) $(CFLAGS) uformat.c
7676

77-
bcread.obj:
77+
bcread.obj: kitten.h
7878
$(CC) $(CFLAGS) bcread.c
7979

8080
prf.obj:
@@ -83,6 +83,9 @@ prf.obj:
8383
kitten.obj: kitten.h
8484
$(CC) $(CFLAGS) kitten.c
8585

86+
msghlpr.obj: kitten.h
87+
$(CC) $(CFLAGS) msghlpr.c
88+
8689

8790
# clean up:
8891

savefs.c

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// Module Description: Save File System Function
1616
*/
1717

18+
#include <string.h> /* strncmp */
1819

1920
#include "format.h"
2021
#include "floppy.h"
@@ -23,8 +24,8 @@
2324
#include "savefs.h"
2425
#include "hdisk.h" /* Force_Drive_Recheck */
2526
#include "userint.h" /* Display_Percentage_Formatted */
27+
#include "msghlpr.h"
2628

27-
#include <string.h> /* strncmp */
2829

2930

3031

@@ -35,10 +36,19 @@ void MMapWrite(unsigned long mmapsec, unsigned long * mmapbuf)
3536
memcpy((void *)&sector_buffer[0], (void *)mmapbuf, 512);
3637
if (debug_prog==TRUE) printf(" [map %lu] ", mmapsec);
3738
if (Drive_IO(WRITE, mmapsec, -1) != 0)
38-
printf("Cannot write MIRROR MAP sector %lu - UNFORMAT spoiled!\n",
39+
printf(catgets(catalog, 23, 0, "Cannot write MIRROR MAP sector %lu - UNFORMAT spoiled!\n"),
3940
mmapsec);
4041
}
4142

43+
/* detailed help screen messages */
44+
char const * const properties_not_preserved[] = {
45+
"Filesystem properties will change, cannot preserve the\n",
46+
"(possibly empty) old bad cluster list. Use a surface scan\n",
47+
"tool or FORMAT /U if you want to update the bad cluster list.\n",
48+
NULL
49+
};
50+
51+
4252
/* Save the old file system for possible recovery with unformat */
4353
/* Used for SafeFormat and MIRROR, as you might have guessed... */
4454
/* *** WARNING: This only works if (...) the root directory follows *** */
@@ -113,29 +123,29 @@ void Save_File_System(int overwrite)
113123

114124
if ( BSWord(0x0b) != 512 )
115125
{
116-
printf("Not 512 bytes / sector. Cannot save UNFORMAT data.\n");
126+
printf(catgets(catalog, 23, 1, "Not 512 bytes / sector. Cannot save UNFORMAT data.\n"));
117127
bad_boot_sector = TRUE;
118128
}
119129

120130
number_of_fats = sector_buffer[0x10];
121131
if ( (number_of_fats < 1) || (number_of_fats > 2) )
122132
{
123-
printf("Not 1 or 2 FAT copies. Cannot save UNFORMAT data.\n");
133+
printf(catgets(catalog, 23, 2, "Not 1 or 2 FAT copies. Cannot save UNFORMAT data.\n"));
124134
bad_boot_sector = TRUE;
125135
}
126136

127137
reserved_sectors = BSWord(0x0e);
128138
if ((param.fat_type != FAT32) && (reserved_sectors != 1))
129139
{
130-
printf("WARNING: Number of reserved / boot sectors is %u, not 1.\n",
140+
printf(catgets(catalog, 23, 3, "WARNING: Number of reserved / boot sectors is %u, not 1.\n"),
131141
reserved_sectors);
132142
if ((reserved_sectors < 1) || (reserved_sectors > 64))
133143
bad_boot_sector = TRUE;
134144
}
135145
if ((param.fat_type == FAT32) &&
136146
(reserved_sectors != parameter_block.bpb.reserved_sectors))
137147
{
138-
printf("WARNING: Reserved sectors are %u but will be %u after format.\n",
148+
printf(catgets(catalog, 23, 4, "WARNING: Reserved sectors are %u but will be %u after format.\n"),
139149
reserved_sectors, parameter_block.bpb.reserved_sectors);
140150
if ((reserved_sectors < 1) || (reserved_sectors > 64)) /* no ; */
141151
bad_boot_sector = TRUE;
@@ -146,18 +156,18 @@ void Save_File_System(int overwrite)
146156
(BSWord(0x16) == 0) ) /* FAT1x size zero? */
147157
&& (fat_type != FAT32))
148158
{
149-
printf(" Must be FAT32, not %s!\n",
159+
printf(catgets(catalog, 23, 5, " Must be FAT32, not %s!\n"),
150160
(fat_type == FAT12) ? "FAT12" : "FAT16");
151161
/* 0 root dir entries or FAT1x size in Save_File_System */
152162

153163
nomirror_wimp: /* common bailout point avoids duplicated code (0.91p) */
154164

155-
printf(" NOT saving unformat info, not preserving bad cluster list.\n");
165+
printf(catgets(catalog, 23, 6, " NOT saving unformat info, not preserving bad cluster list.\n"));
156166
return;
157167
}
158168
if ( (number_of_root_directory_entries != 0) && (fat_type == FAT32) )
159169
{
160-
printf("WARNING: FAT32 with FAT1x style extra Root Directory???\n");
170+
printf(catgets(catalog, 23, 7, "WARNING: FAT32 with FAT1x style extra Root Directory???\n"));
161171
goto nomirror_wimp; /* 0.91p */
162172
}
163173

@@ -172,20 +182,20 @@ void Save_File_System(int overwrite)
172182
sectors_per_fat = BSLong(0x24);
173183
if (fat_type != FAT32)
174184
{
175-
printf(" Must be FAT32, not FAT1x!\n");
185+
printf(catgets(catalog, 23, 8, " Must be FAT32, not FAT1x!\n"));
176186
goto nomirror_wimp; /* 0.91p */
177187
}
178188
}
179189
else
180190
{ /* FAT1x case: 16bit sectors per fat value nonzero */
181191
if (number_of_root_directory_entries == 0)
182192
{
183-
printf(" FAT32 Root Directory but FAT1x FAT!\n");
193+
printf(catgets(catalog, 23, 9, " FAT32 Root Directory but FAT1x FAT!\n"));
184194
goto nomirror_wimp; /* 0.91p */
185195
}
186196
if (fat_type != ( (sectors_per_fat <= 12) ? FAT12 : FAT16 ))
187197
{
188-
printf(" %s size but supposed to be FAT32!\n",
198+
printf(catgets(catalog, 23, 10, " %s size but supposed to be FAT32!\n"),
189199
(sectors_per_fat <= 12) ? "FAT12" : "FAT16");
190200
goto nomirror_wimp; /* 0.91p */
191201
}
@@ -203,13 +213,13 @@ void Save_File_System(int overwrite)
203213
(sectors_per_fat < 1) ||
204214
(number_of_logical_sectors_on_drive < 200) )
205215
{ /* not plausible root directory or FAT or drive size */
206-
printf(" Implausible Root Directory, FAT or drive size! Bad boot sector?\n");
216+
printf(catgets(catalog, 23, 11, " Implausible Root Directory, FAT or drive size! Bad boot sector?\n"));
207217
bad_boot_sector = TRUE; /* -ea */
208218
} else {
209219
if ( ( 1 + sectors_per_fat + (number_of_root_directory_entries >> 4) +
210220
5 ) > ( number_of_logical_sectors_on_drive >> 1 ) ) /* estimate only */
211221
{
212-
printf(" Big FAT for little data? Bad boot sector?\n");
222+
printf(catgets(catalog, 23, 12, " Big FAT for little data? Bad boot sector?\n"));
213223
bad_boot_sector = TRUE;
214224
}
215225
} /* root directory an FAT and drive size was plausible */
@@ -236,7 +246,7 @@ void Save_File_System(int overwrite)
236246
}
237247

238248
if (BSLong(0x2c) != 2)
239-
printf("Root Directory NOT in 1st cluster, NOT saving it!\n");
249+
printf(catgets(catalog, 23, 13, "Root Directory NOT in 1st cluster, NOT saving it!\n"));
240250
/* would have to change some code below to save it properly... */
241251
}
242252
else
@@ -261,7 +271,7 @@ void Save_File_System(int overwrite)
261271
/* If the boot sector is not any good, don't save the file system. */
262272
if (bad_boot_sector==TRUE)
263273
{
264-
printf(" Drive looks unformatted, UNFORMAT information NOT saved.\n");
274+
printf(catgets(catalog, 23, 14, " Drive looks unformatted, UNFORMAT information NOT saved.\n"));
265275
/* not preserving "existing" bad cluster list either, of course! */
266276
return;
267277
}
@@ -282,15 +292,13 @@ void Save_File_System(int overwrite)
282292
else
283293
{
284294
unsigned long scratch;
285-
printf("Filesystem properties will change, cannot preserve the\n");
286-
printf("(possibly empty) old bad cluster list. Use a surface scan\n");
287-
printf("tool or FORMAT /U if you want to update the bad cluster list.\n");
295+
Print_Messages_With_Pauses(catalog, 24, properties_not_preserved);
288296

289297
if (reserved_sectors != parameter_block.bpb.reserved_sectors)
290-
printf("Number of reserved sectors differs: FOUND %lu / PLANNED %u.\n",
298+
printf(catgets(catalog, 23, 15, "Number of reserved sectors differs: FOUND %lu / PLANNED %u.\n"),
291299
reserved_sectors, parameter_block.bpb.reserved_sectors);
292300
if (number_of_fats != parameter_block.bpb.number_of_fats)
293-
printf("Number of FATs differs: FOUND %lu / PLANNED %hu\n",
301+
printf(catgets(catalog, 23, 16, "Number of FATs differs: FOUND %lu / PLANNED %hu\n"),
294302
number_of_fats, parameter_block.bpb.number_of_fats);
295303
if (sectors_per_cluster != BPB_SECTORS_PER_CLUSTER(parameter_block.bpb))
296304
printf("Cluster size differs: FOUND %lu / PLANNED %hu (sectors)\n",

userint.c

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "format.h"
2727
#include "userint.h"
28+
#include "msghlpr.h"
2829

2930

3031
#define KEYGET_ECHO regs.h.ah = 0x07; /* Get keypress, upcase and echo */ \
@@ -476,51 +477,6 @@ void Display_Invalid_Combination()
476477
} /* Display_Invalid_Combination */
477478

478479

479-
void Key_For_Next_Page(void);
480-
481-
void Key_For_Next_Page()
482-
{
483-
if (!isatty(1))
484-
return; /* redirected? then do not wait. */
485-
/* interesting: redirection to MORESYS (>MORE$) still is a TTY */
486-
/* redirection to a file is not a TTY, so waiting is avoided :-) */
487-
488-
printf(catgets(catalog, 14, 1, "-- press enter to see the next page or ESC to abort --"));
489-
490-
/* Get keypress */
491-
regs.h.ah = 0x07;
492-
intdos(&regs, &regs);
493-
if (regs.h.al == 27)
494-
{
495-
printf(catgets(catalog, 14, 2, "\nAborted at user request.\n"));
496-
Exit(3,13);
497-
}
498-
499-
printf("\n\n");
500-
501-
} /* Key_For_Next_Page */
502-
503-
504-
void Print_Messages_With_Pauses(nl_catd catalog, int setnum, char const * const messages[])
505-
{
506-
int msgnum = 0;
507-
int use_cats = (catgets(catalog, setnum, 0, NULL) != NULL);
508-
char const * msg;
509-
510-
for (msg=(use_cats)?catgets(catalog, setnum, msgnum, NULL):messages[msgnum];
511-
msg != NULL;
512-
msgnum++, msg=(use_cats)?catgets(catalog, setnum, msgnum, NULL):messages[msgnum])
513-
{
514-
printf("%s", msg);
515-
if (msgnum && !(msgnum % 22)) /* every 23rd line after initial line */
516-
{
517-
if (memcmp(msg, "\n", 2) != 0) printf("\n"); /* add blank unless just printed a blank line */
518-
Key_For_Next_Page();
519-
}
520-
}
521-
} /* Print_Messages_With_Pauses */
522-
523-
524480
/* short help screen */
525481
char const * const short_help[] = {
526482
#if LEGACY_HELP /* with legacy stuff */

0 commit comments

Comments
 (0)