Skip to content

Commit

Permalink
Don't cast LINENUM to int.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Nov 24, 2002
1 parent ea95634 commit 9c7c3fb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
38 changes: 19 additions & 19 deletions linenum.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
* Structure to keep track of a line number and the associated file position.
* A doubly-linked circular list of line numbers is kept ordered by line number.
*/
struct linenum
struct linenum_info
{
struct linenum *next; /* Link to next in the list */
struct linenum *prev; /* Line to previous in the list */
struct linenum_info *next; /* Link to next in the list */
struct linenum_info *prev; /* Line to previous in the list */
POSITION pos; /* File position */
POSITION gap; /* Gap between prev and next */
LINENUM line; /* Line number */
Expand All @@ -62,10 +62,10 @@ struct linenum

public int lnloop = 0; /* Are we in the line num loop? */

static struct linenum anchor; /* Anchor of the list */
static struct linenum *freelist; /* Anchor of the unused entries */
static struct linenum pool[NPOOL]; /* The pool itself */
static struct linenum *spare; /* We always keep one spare entry */
static struct linenum_info anchor; /* Anchor of the list */
static struct linenum_info *freelist; /* Anchor of the unused entries */
static struct linenum_info pool[NPOOL]; /* The pool itself */
static struct linenum_info *spare; /* We always keep one spare entry */

extern int linenums;
extern int sigs;
Expand All @@ -77,7 +77,7 @@ extern int sc_height;
public void
clr_linenum()
{
register struct linenum *p;
register struct linenum_info *p;

/*
* Put all the entries on the free list.
Expand All @@ -104,7 +104,7 @@ clr_linenum()
*/
static void
calcgap(p)
register struct linenum *p;
register struct linenum_info *p;
{
/*
* Don't bother to compute a gap for the anchor.
Expand All @@ -127,10 +127,10 @@ add_lnum(linenum, pos)
LINENUM linenum;
POSITION pos;
{
register struct linenum *p;
register struct linenum *new;
register struct linenum *nextp;
register struct linenum *prevp;
register struct linenum_info *p;
register struct linenum_info *new;
register struct linenum_info *nextp;
register struct linenum_info *prevp;
register POSITION mingap;

/*
Expand Down Expand Up @@ -257,7 +257,7 @@ longish()
find_linenum(pos)
POSITION pos;
{
register struct linenum *p;
register struct linenum_info *p;
register LINENUM linenum;
POSITION cpos;

Expand Down Expand Up @@ -366,7 +366,7 @@ find_linenum(pos)
find_pos(linenum)
LINENUM linenum;
{
register struct linenum *p;
register struct linenum_info *p;
POSITION cpos;
LINENUM clinenum;

Expand Down Expand Up @@ -437,16 +437,16 @@ currline(where)
{
POSITION pos;
POSITION len;
LINENUM lnum;
LINENUM linenum;

pos = position(where);
len = ch_length();
while (pos == NULL_POSITION && where >= 0 && where < sc_height)
pos = position(++where);
if (pos == NULL_POSITION)
pos = len;
lnum = find_linenum(pos);
linenum = find_linenum(pos);
if (pos == len)
lnum--;
return (lnum);
linenum--;
return (linenum);
}
21 changes: 17 additions & 4 deletions prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ ap_pos(pos)
ap_str(p);
}

/*
* Append a line number to the end of the message.
*/
static void
ap_linenum(linenum)
LINENUM linenum;
{
/*
* Assume sizeof(LINENUM) <= sizeof(POSITION).
*/
ap_pos((POSITION)linenum);
}

/*
* Append an integer to the end of the message.
*/
Expand Down Expand Up @@ -265,7 +278,7 @@ protochar(c, where, iseditproto)
case 'd': /* Current page number */
linenum = currline(where);
if (linenum > 0 && sc_height > 1)
ap_int(((linenum - 1) / (sc_height - 1)) + 1);
ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);
else
ap_quest();
break;
Expand All @@ -275,7 +288,7 @@ protochar(c, where, iseditproto)
(linenum = find_linenum(len)) <= 0)
ap_quest();
else
ap_int(((linenum - 1) / (sc_height - 1)) + 1);
ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);
break;
#if EDITOR
case 'E': /* Editor name */
Expand All @@ -296,7 +309,7 @@ protochar(c, where, iseditproto)
case 'l': /* Current line number */
linenum = currline(where);
if (linenum != 0)
ap_int(linenum);
ap_linenum(linenum);
else
ap_quest();
break;
Expand All @@ -306,7 +319,7 @@ protochar(c, where, iseditproto)
(linenum = find_linenum(len)) <= 0)
ap_quest();
else
ap_int(linenum-1);
ap_linenum(linenum-1);
break;
case 'm': /* Number of files */
#if TAGS
Expand Down

0 comments on commit 9c7c3fb

Please sign in to comment.