annotate 3rdparty/packages/ed/getone.c @ 2822:4ffb283f6233 lwtools-port

Forgot to add to makefile
author Boisy Pitre <boisy.pitre@nuance.com>
date Wed, 22 May 2013 17:04:29 -0500
parents bef1844de0dc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
994
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
1 /* getone.c */
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
2 #include <stdio.h>
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
3 #include "tools.h"
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
4 #include "ed.h"
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
5
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
6 #define FIRST 1
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
7 #define NOTFIRST 0
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
8
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
9 int getone()
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
10 {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
11 int c, i, num;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
12
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
13 if ((num = getnum(FIRST)) >= 0) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
14 while (1) {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
15 while (*inptr == SP || *inptr == HT) inptr++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
16
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
17 if (*inptr != '+' && *inptr != '-') break;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
18 c = *inptr++;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
19
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
20 if ((i = getnum(NOTFIRST)) < 0) return(i);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
21
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
22 if (c == '+') {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
23 num += i;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
24 } else {
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
25 num -= i;
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
26 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
27 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
28 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
29 return(num > lastln ? ERR : num);
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
30 }
bef1844de0dc The ED editor ported from Minix
roug
parents:
diff changeset
31