summaryrefslogtreecommitdiff
path: root/ipl/progs/comply83.icn
blob: 0d43c0fc268ea824a21dccf934ed814f08815170 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
############################################################################
#
#	File:     comply83.icn
#
#	Subject:  Program to check compliance with MS-DOS name restrictions
#
#	Author:   Ralph E. Griswold
#
#	Date:     October 4, 1997
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  This program checks the file names given on standard input and reports
#  any that are not valid MS-DOS file names.
#
#  It is designed handle output UNIX ls -R, but it will handle a list
#  of file names, one per line.
#  
############################################################################

procedure main()
   local line, base, ext, dir, forbid

   forbid := &cset -- &letters -- &digits -- '._^$~!#%&-{}()@\'`'

   while line := read() do {
      if *line = 0 then next			# skip blank lines
      line ? {
         if upto(forbid, line) then {		# contains forbidden character
            write(dir, line)
            next
            }
         if = "." then {			# directory header
            dir := tab(-1) || "/"
            next
            }
         if base := tab(upto('.')) then {
            move(1)
            ext := tab(0)
            ext ? {
               if upto('.') then {		# period in "extension"
                  write(dir, line)
                  next
                  }
               }
            }
         else {
            base := tab(0)
            ext := ""
            }
         if (*base > 8) | (*ext > 3) then	# check sizes
            write(dir, line)
         }
      }

end