]>
git.saurik.com Git - apple/file_cmds.git/blob - file/internat.c
3609fddc91636af5b8fbbb0cdc7515e1b0e9eba3
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
24 /* $OpenBSD: internat.c,v 1.1 1997/02/09 23:58:26 millert Exp $ */
27 #include <sys/types.h>
35 * List of characters that look "reasonable" in international
36 * language texts. That's almost all characters :), except a
37 * few in the control range of ASCII (all the known international
38 * charactersets share the bottom half with ASCII).
40 static char maybe_internat
[256] = {
41 F
, F
, F
, F
, F
, F
, F
, F
, T
, T
, T
, T
, T
, T
, F
, F
, /* 0x0X */
42 F
, F
, F
, F
, F
, F
, F
, F
, F
, F
, F
, T
, F
, F
, F
, F
, /* 0x1X */
43 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0x2X */
44 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0x3X */
45 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0x4X */
46 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0x5X */
47 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0x6X */
48 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, F
, /* 0x7X */
49 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0x8X */
50 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0x9X */
51 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0xaX */
52 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0xbX */
53 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0xcX */
54 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0xdX */
55 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, /* 0xeX */
56 T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
, T
/* 0xfX */
59 /* Maximal length of a line we consider "reasonable". */
60 #define MAXLINELEN 300
63 internatmagic(buf
, nbytes
)
72 /* First, look whether there are "unreasonable" characters. */
73 for (i
= 0, cp
= buf
; i
< nbytes
; i
++, cp
++)
74 if (!maybe_internat
[*cp
])
78 * Now, look whether the file consists of lines of
79 * "reasonable" length.
82 for (i
= 0; i
< nbytes
;) {
83 cp
= memchr(buf
, '\n', nbytes
- i
);
85 /* Don't fail if we hit the end of buffer. */
86 if (i
+ MAXLINELEN
>= nbytes
)
91 if (cp
- buf
> MAXLINELEN
)
96 ckfputs("International language text", stdout
);