Files
taiji/sys/lib/ghostscript/xlatmap
T
Russ Cox 535bf48a25 all: remove trailing spaces in text files
To avoid acme making spurious edits in future changes,
edited all text files to remove end-of-line spaces and tabs,
remove trailing blank lines, and add missing final newlines,
using this Go program.

package main

import (
	"bytes"
	"fmt"
	"log"
	"os"
	"path/filepath"
	"regexp"
	"unicode/utf8"
)

var blank = []byte("\n\n")

func main() {
	log.SetPrefix("fixspace: ")
	log.SetFlags(0)

	re := regexp.MustCompile(`(?m)[ \t]+$`)
	filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
		if err != nil {
			log.Print(err)
			return nil
		}
		if info.IsDir() {
			return nil
		}
		old, err := os.ReadFile(path)
		if err != nil {
			return err
		}
		if !utf8.Valid(old) || bytes.ContainsAny(old, "\x00\r") {
			return nil
		}

		// Remove trailing spaces at ends of lines.
		new := re.ReplaceAll(old, nil)

		// Remove trailing blank lines.
		for len(new) > 0 && bytes.HasSuffix(new, blank) {
			new = new[:len(new)-1]
		}
		if len(new) == 1 && new[0] == '\n' {
			new = nil
		}

		// Add newline at end of line if needed.
		if len(new) > 0 && new[len(new)-1] != '\n' {
			new = append(new, '\n')
		}

		if !bytes.Equal(old, new) {
			if err := os.WriteFile(path, new, 0666); err != nil {
				log.Print(err)
				return nil
			}
			fmt.Printf("%s\n", path)
		}
		return nil
	})
}
2025-03-09 08:26:49 -04:00

50 lines
1.7 KiB
Plaintext
Executable File

% xlatmap - the map of translation tables for various kinds of fonts.
%
% It specifies Decoding resources to be used with FAPI-handled fonts.
% If a font contains multiple character mapping tables, this gives
% priorities for choosing a specific table from the font according to
% the order of entries of this map.
% This file is intended to be customized by users. Please keep the
% obvious format of this file. Strings and names must not be empty
% and must not contain null ('\0') characters.
% $Id: xlatmap,v 1.7 2002/11/02 18:03:06 igor Exp $
% The map contains entries for each kind of font being handled by
% any font rendering plugin. The key of an entry is the font type
% and the value is array of pairs.
% The first element of pair is a string which encodes identifier of
% character mapping table. The format of the first element depends
% on the font type, and should be recognized by the font rendering
% plugins. The second element is name of the Decoding resource. If
% that resource is not available, definefont will fail. Note that
% currently we supply insufficient decoding resources, as well as
% insufficient entries in this map.
/TrueType
[ % Each entry is pair :
% a string PlatformID.SpecificID and a name of Decoding resource.
(3.0) /Symbol % Symbol
(3.1) /Unicode % Unicode
(3.2) /ShiftJIS % Japanese
(3.3) /PRC % Simplified Chinese, GB2312
(3.4) /Big5 % Traditional Chinese
(3.5) /Wansung % Korean
(3.6) /Johab % Korean
% todo : add more entries
]
/PostScript
[ % Since PostScript fonts were designed especially for PostScript,
(*) /Latin1 % fixme : other charsets
]
/Intellifont
[ (*) /Latin1 % fixme : other charsets
]
/Microtype
[ (*) /Latin1 % fixme : other charsets
]