File: utilX11FontNames.c

package info (click to toggle)
ted 2.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,944 kB
  • ctags: 20,273
  • sloc: ansic: 167,980; makefile: 12,518; sh: 263
file content (79 lines) | stat: -rw-r--r-- 1,435 bytes parent folder | download | duplicates (2)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#   include	"appUtilConfig.h"

#   include	<stdio.h>
#   include	<stdlib.h>
#   include	<string.h>
#   include	<ctype.h>

#   include	"utilX11FontNames.h"

#   include	<appDebugon.h>

/************************************************************************/
/*									*/
/*  Split an X11 fonts dir line.					*/
/*									*/
/*  Return 0 on success.						*/
/*  Return 1 on a line that can be skipped: The first line with the	*/
/*	count.								*/
/*  Return -1 on illegal input.						*/
/*									*/
/************************************************************************/

int utilX11SplitFontsDirLine(		char *		scratch,
					int *		pX11Start,
					int *		pX11Length,
					int		line )
    {
    int		digitsOnly= 1;
    char *	s= scratch;
    int		past;
    int		j;

    while( *s && ! isspace( *s ) )
	{
	if  ( ! isdigit( *s ) )
	    { digitsOnly= 0;	}
	s++;
	}

    if  ( ! *s )
	{
	if  ( line != 0 || ! digitsOnly )
	    { LSDEB(line,scratch); return -1;	}

	return 1;
	}

    *(s++)= '\0';
    while( isspace( *s ) )
	{ s++;	}
    if  ( ! *s )
	{
	if  ( line != 0 || ! digitsOnly )
	    { LSDEB(line,scratch); return -1;	}
	
	return 1;
	}

    past= -1;

    j= 0;
    while( s[j] )
	{
	if  ( s[j] == ' ' || s[j] == '\t' || s[j] == '\n' )
	    { past= j;	}
	else{ past= -1;	}

	j++;
	}

    if  ( past >= 0 )
	{ s[past]= '\0';	}
    else{ past= j;		}

    *pX11Start= s- scratch;
    *pX11Length= past;
    return 0;
    }