[Pinfo-devel] r215 - pinfo/trunk/src
Bas Zoetekouw
bas at costa.debian.org
Thu Sep 8 20:33:48 UTC 2005
Author: bas
Date: 2005-09-08 20:33:44 +0000 (Thu, 08 Sep 2005)
New Revision: 215
Modified:
pinfo/trunk/src/initializelinks.c
pinfo/trunk/src/pinfo.c
Log:
*ARGRG*
- rewrap code to make it fit in my terminal window
- introduced some if's in this code to the concept of && and ||
- removed some evil goto's
Modified: pinfo/trunk/src/initializelinks.c
===================================================================
--- pinfo/trunk/src/initializelinks.c 2005-09-08 14:04:14 UTC (rev 214)
+++ pinfo/trunk/src/initializelinks.c 2005-09-08 20:33:44 UTC (rev 215)
@@ -234,44 +234,53 @@
do
{
changed = 0;
- if ((quotestart = strchr(quoteend, '`')) != NULL) /* find start of quoted text */
+ /* find start of quoted text */
+ if ( ((quotestart = strchr(quoteend, '`')) != NULL)
+ /* if it's in the first line of the two glued together */
+ && (quotestart < buf + line1len)
+ /* find the end of quoted text */
+ && ((quoteend = strchr(quotestart, '\'')) != NULL)
+ && (quoteend - quotestart > 1))
{
- if (quotestart < buf + line1len) /* if it's in the first line of the two glued together */
- if ((quoteend = strchr(quotestart, '\'')) != NULL) /* find the end of quoted text */
+ /* if this apostrophe is not a part of "haven't",
+ * "wouldn't", etc. */
+ while (!strncmp(quoteend - 1, "n't", 3))
+ {
+ quoteend = strchr(quoteend + 1, '\'');
+ if (!quoteend)
+ break;
+ }
+ if (quoteend)
+ {
+ changed = 1;
+ if (!hyperobjectcount)
+ hyperobjects = xmalloc(sizeof(HyperObject));
+ else
{
- if (quoteend - quotestart > 1)
- {
- while (!strncmp(quoteend - 1, "n't", 3)) /* if this apostrophe is not a part of "haven't", "wouldn't", etc. */
- {
- quoteend = strchr(quoteend + 1, '\'');
- if (!quoteend)
- break;
- }
- if (quoteend)
- {
- changed = 1;
- if (!hyperobjectcount)
- hyperobjects = xmalloc(sizeof(HyperObject));
- else
- hyperobjects = xrealloc(hyperobjects, sizeof(HyperObject) *(hyperobjectcount + 1));
- hyperobjects[hyperobjectcount].line = line;
- hyperobjects[hyperobjectcount].col = calculate_len(buf, quotestart + 1);
- hyperobjects[hyperobjectcount].breakpos = -1; /* default */
- if (quoteend > buf + line1len)
- {
- hyperobjects[hyperobjectcount].breakpos = buf + line1len - quotestart - 1;
- }
- hyperobjects[hyperobjectcount].type = HIGHLIGHT;
- strncpy(hyperobjects[hyperobjectcount].node, quotestart + 1, quoteend - quotestart - 1);
- hyperobjects[hyperobjectcount].node[quoteend - quotestart - 1] = 0;
- strcpy(hyperobjects[hyperobjectcount].file, "");
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
- hyperobjects[hyperobjectcount].tagtableoffset = -1;
- hyperobjectcount++;
- }
- }
+ hyperobjects = xrealloc(hyperobjects,
+ sizeof(HyperObject) *(hyperobjectcount + 1));
}
+ hyperobjects[hyperobjectcount].line = line;
+ hyperobjects[hyperobjectcount].col =
+ calculate_len(buf, quotestart + 1);
+ hyperobjects[hyperobjectcount].breakpos = -1; /* default */
+ if (quoteend > buf + line1len)
+ {
+ hyperobjects[hyperobjectcount].breakpos =
+ buf + line1len - quotestart - 1;
+ }
+ hyperobjects[hyperobjectcount].type = HIGHLIGHT;
+ strncpy( hyperobjects[hyperobjectcount].node,
+ quotestart + 1, quoteend - quotestart - 1);
+ hyperobjects[hyperobjectcount].node[quoteend - quotestart - 1] = 0;
+ strcpy(hyperobjects[hyperobjectcount].file, "");
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].tagtableoffset = -1;
+ hyperobjectcount++;
+ }
}
}
while (changed);
@@ -288,16 +297,22 @@
if (!hyperobjectcount)
hyperobjects = xmalloc(sizeof(HyperObject));
else
- hyperobjects = xrealloc(hyperobjects, sizeof(HyperObject) *(hyperobjectcount + 1));
+ {
+ hyperobjects = xrealloc(hyperobjects,
+ sizeof(HyperObject) *(hyperobjectcount + 1));
+ }
hyperobjects[hyperobjectcount].line = line;
hyperobjects[hyperobjectcount].col = calculate_len(line1, urlstart);
hyperobjects[hyperobjectcount].breakpos = -1;
hyperobjects[hyperobjectcount].type = 6;
- strncpy(hyperobjects[hyperobjectcount].node, urlstart, urlend - urlstart);
+ strncpy(hyperobjects[hyperobjectcount].node,
+ urlstart, urlend - urlstart);
hyperobjects[hyperobjectcount].node[urlend - urlstart] = 0;
strcpy(hyperobjects[hyperobjectcount].file, "");
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
hyperobjects[hyperobjectcount].tagtableoffset = -1;
if (strchr(hyperobjects[hyperobjectcount].node, '.') == NULL)
{
@@ -317,22 +332,26 @@
if ((line1[0] == '*') &&(line1[1] == ' ')) /* menu */
{
- /******************************************************************************
- * Scan for normal menu of kind "*(infofile)reference:: comment", where *
- * the infofile parameter is optional, and indicates, that a reference *
- * matches different info file. *
- ******************************************************************************/
+ /*************************************************************************
+ * Scan for normal menu of kind "*(infofile)reference:: comment", where *
+ * the infofile parameter is optional, and indicates, that a reference *
+ * matches different info file. *
+ *************************************************************************/
tmp = strstr(line1, "::"); /* "* menulink:: comment" */
if (tmp != NULL)
{
if (!hyperobjectcount)
hyperobjects = xmalloc(sizeof(HyperObject));
else
- hyperobjects = xrealloc(hyperobjects, sizeof(HyperObject) *(hyperobjectcount + 1));
+ {
+ hyperobjects = xrealloc(hyperobjects,
+ sizeof(HyperObject) *(hyperobjectcount + 1));
+ }
if (line1[2] == '(') /* if cross-info link */
{
char *end = strchr(line1, ')');
- if ((end != NULL) &&(end < tmp)) /* if the ')' char was found, and was before '::' */
+ /* if the ')' char was found, and was before '::' */
+ if ((end != NULL) &&(end < tmp))
{
long FilenameLen =(long)(end - line1 - 3);
long NodenameLen =(long)(tmp - end - 1);
@@ -346,14 +365,16 @@
hyperobjects[hyperobjectcount].line = line;
hyperobjects[hyperobjectcount].col = 2;
hyperobjects[hyperobjectcount].breakpos = -1;
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
hyperobjectcount++;
}
}
else
+ {
/* if not cross-info link */
- {
long NodenameLen =(long)(tmp - line1 - 2);
int goodHit = 0;
strcpy(hyperobjects[hyperobjectcount].file, "");
@@ -364,66 +385,69 @@
hyperobjects[hyperobjectcount].line = line;
hyperobjects[hyperobjectcount].col = 2;
hyperobjects[hyperobjectcount].breakpos = -1;
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
if (exists_in_tag_table(hyperobjects[hyperobjectcount].node))
{
hyperobjectcount++; /* yep, this was a good hit */
goodHit = 1;
}
- if (!goodHit)
+ if (!goodHit && !hyperobjectcount)
{
- if (!hyperobjectcount)
- {
- xfree(hyperobjects);
- hyperobjects = 0;
- }
+ xfree(hyperobjects);
+ hyperobjects = 0;
}
}
}
- /******************************************************************************
- * Scan for menu references of form *
- * "* Comment:[spaces](infofile)reference." *
+ /************************************************************
+ * Scan for menu references of form *
+ * "* Comment:[spaces](infofile)reference." *
******************************************************************************/
else if ((tmp = strrchr(line1, ':')) != NULL)
{
char *start = 0, *end = 0, *dot = 0;
- dot = finddot(tmp + 1, MENU_DOT); /* find the trailing dot */
- if (dot != NULL)
- if (dot + 7 < dot + strlen(dot))
- {
- /* skip possible '.info' filename suffix when searching for ending dot */
- if (strncmp(dot, ".info)", 6) == 0)
- dot = finddot(dot + 1, MENU_DOT);
- }
+ /* find the trailing dot */
+ dot = finddot(tmp + 1, MENU_DOT);
+ if (dot != NULL && (dot + 7 < dot + strlen(dot)) )
+ {
+ /* skip possible '.info' filename suffix when
+ * searching for ending dot */
+ if (strncmp(dot, ".info)", 6) == 0)
+ dot = finddot(dot + 1, MENU_DOT);
+ }
/* we make use of sequential AND evaluation: start must not be NULL! */
if (((start = strchr(tmp, '(')) != NULL) &&(dot != NULL) &&
((end = strchr(start, ')')) != NULL))
{
- if (start < dot) /* security mechanism ;) */
+ if ( (start < dot) && (end < dot) ) /* security mechanism ;) */
{
- if (end < dot) /* security mechanism ;)) */
+ long FilenameLen =(long)(end - start - 1);
+ long NodenameLen =(long)(dot - end - 1);
+ if (!hyperobjectcount)
+ hyperobjects = xmalloc(sizeof(HyperObject));
+ else
{
- long FilenameLen =(long)(end - start - 1);
- long NodenameLen =(long)(dot - end - 1);
- if (!hyperobjectcount)
- hyperobjects = xmalloc(sizeof(HyperObject));
- else
- hyperobjects = xrealloc(hyperobjects, sizeof(HyperObject) *(hyperobjectcount + 1));
- strncpy(hyperobjects[hyperobjectcount].file,
- start + 1, FilenameLen);
- hyperobjects[hyperobjectcount].file[FilenameLen] = 0;
- strncpy(hyperobjects[hyperobjectcount].node,
- end + 1, NodenameLen);
- hyperobjects[hyperobjectcount].node[NodenameLen] = 0;
- hyperobjects[hyperobjectcount].type = 1;
- hyperobjects[hyperobjectcount].line = line;
- hyperobjects[hyperobjectcount].col = calculate_len(line1, start);
- hyperobjects[hyperobjectcount].breakpos = -1;
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
- hyperobjectcount++;
+ hyperobjects = xrealloc(hyperobjects,
+ sizeof(HyperObject) *(hyperobjectcount + 1));
}
+ strncpy(hyperobjects[hyperobjectcount].file,
+ start + 1, FilenameLen);
+ hyperobjects[hyperobjectcount].file[FilenameLen] = 0;
+ strncpy(hyperobjects[hyperobjectcount].node,
+ end + 1, NodenameLen);
+ hyperobjects[hyperobjectcount].node[NodenameLen] = 0;
+ hyperobjects[hyperobjectcount].type = 1;
+ hyperobjects[hyperobjectcount].line = line;
+ hyperobjects[hyperobjectcount].col =
+ calculate_len(line1, start);
+ hyperobjects[hyperobjectcount].breakpos = -1;
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjectcount++;
}
else
{
@@ -439,7 +463,10 @@
if (!hyperobjectcount)
hyperobjects = xmalloc(sizeof(HyperObject));
else
- hyperobjects = xrealloc(hyperobjects, sizeof(HyperObject) *(hyperobjectcount + 1));
+ {
+ hyperobjects = xrealloc(hyperobjects,
+ sizeof(HyperObject) *(hyperobjectcount + 1));
+ }
start = tmp + 1; /* move after the padding spaces */
while (isspace(*start))
@@ -453,20 +480,19 @@
hyperobjects[hyperobjectcount].line = line;
hyperobjects[hyperobjectcount].col = calculate_len(line1, start);
hyperobjects[hyperobjectcount].breakpos = -1;
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
if (exists_in_tag_table(hyperobjects[hyperobjectcount].node))
{
hyperobjectcount++; /* yep, this was a good hit */
goodHit = 1;
}
- if (!goodHit)
+ if (!goodHit && !hyperobjectcount)
{
- if (!hyperobjectcount)
- {
- xfree(hyperobjects);
- hyperobjects = 0;
- }
+ xfree(hyperobjects);
+ hyperobjects = 0;
}
}
}
@@ -475,21 +501,20 @@
/******************************************************************************
* Handle notes. In similar way as above. *
******************************************************************************/
- else if ((notestart = strstr(buf, "*note")) != NULL)
- goto handlenote;
- else if ((notestart = strstr(buf, "*Note")) != NULL)
+ else if ( ( (notestart = strstr(buf, "*note")) != NULL )
+ || ( (notestart = strstr(buf, "*Note")) != NULL ) )
{
-handlenote:
- /******************************************************************************
- * Scan for normal note of kind "*(infofile)reference:: comment", where *
- * the infofile parameter is optional, and indicates, that a reference *
- * matches different info file. *
- ******************************************************************************/
+ /*************************************************************************
+ * Scan for normal note of kind "*(infofile)reference:: comment", where *
+ * the infofile parameter is optional, and indicates, that a reference *
+ * matches different info file. *
+ *************************************************************************/
/* make sure that we don't handle notes, which fit in the second line */
/* Signed-unsigned issues FIXME */
if ((long)(notestart - buf) < strlen(line1))
{
- /* we can handle only those, who are in the first line, or who are split up into two lines */
+ /* we can handle only those, who are in the first line,
+ * or who are split up into two lines */
tmp = strstr(notestart, "::"); /* "*note notelink:: comment" */
if (tmp != NULL)
{
@@ -500,7 +525,8 @@
if (notestart[6] == '(') /* if cross-info link */
{
char *end = strchr(notestart, ')');
- if ((end != NULL) &&(end < tmp)) /* if the ')' char was found, and was before '::' */
+ /* if the ')' char was found, and was before '::' */
+ if ((end != NULL) &&(end < tmp))
{
long FilenameLen =(long)(end - notestart - 7);
long NodenameLen =(long)(tmp - end - 1);
@@ -517,22 +543,36 @@
hyperobjects[hyperobjectcount].col = calculate_len(buf, notestart + 7);
/* if the note highlight fits int first line */
if (tmp - buf < strlen(line1))
+ {
+ /* we don't need to break highlighting
+ * into several lines */
hyperobjects[hyperobjectcount].breakpos = -1;
- /* we don't need to break highlighting int several lines */
+ }
else
- hyperobjects[hyperobjectcount].breakpos = strlen(line1) -(long)(notestart + 7 - buf) + 1; /* otherwise we need it */
+ {
+ /* otherwise we need it */
+ hyperobjects[hyperobjectcount].breakpos =
+ strlen(line1) -(long)(notestart + 7 - buf) + 1;
+ }
}
else
{
hyperobjects[hyperobjectcount].line = line + 1;
- hyperobjects[hyperobjectcount].col = calculate_len(buf + strlen(line1), notestart + 7);
+ hyperobjects[hyperobjectcount].col =
+ calculate_len(buf + strlen(line1), notestart + 7);
if (tmp - buf < strlen(line1)) /* as above */
hyperobjects[hyperobjectcount].breakpos = -1;
- else if ((hyperobjects[hyperobjectcount].breakpos = strlen(line1) -(long)(notestart + 7 - buf) + 1) == 0)
+ else if ((hyperobjects[hyperobjectcount].breakpos =
+ strlen(line1) -
+ (long)(notestart + 7 - buf) + 1) == 0)
+ {
hyperobjects[hyperobjectcount].line--;
+ }
}
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
hyperobjectcount++;
}
}
@@ -545,95 +585,122 @@
notestart + 6, NodenameLen);
hyperobjects[hyperobjectcount].node[NodenameLen] = 0;
hyperobjects[hyperobjectcount].type = 2;
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
if (notestart + 7 - buf < strlen(line1))
{
hyperobjects[hyperobjectcount].line = line;
- hyperobjects[hyperobjectcount].col = calculate_len(buf, notestart + 7) - 1;
+ hyperobjects[hyperobjectcount].col =
+ calculate_len(buf, notestart + 7) - 1;
/* if the note highlight fits int first line */
if (tmp - buf < strlen(line1))
- hyperobjects[hyperobjectcount].breakpos = -1; /* we don't need to break highlighting int several lines */
+ {
+ /* we don't need to break highlighting into
+ * several lines */
+ hyperobjects[hyperobjectcount].breakpos = -1;
+ }
else
- hyperobjects[hyperobjectcount].breakpos = strlen(line1) -(long)(notestart + 7 - buf) + 1; /* otherwise we need it */
+ {
+ /* otherwise we need it */
+ hyperobjects[hyperobjectcount].breakpos =
+ strlen(line1) -(long)(notestart + 7 - buf) + 1;
+ }
}
else
{
hyperobjects[hyperobjectcount].line = line + 1;
- hyperobjects[hyperobjectcount].col = calculate_len(buf + strlen(line1), notestart + 7) - 1;
+ hyperobjects[hyperobjectcount].col =
+ calculate_len(buf + strlen(line1), notestart + 7) - 1;
if (tmp - buf < strlen(line1)) /* as above */
hyperobjects[hyperobjectcount].breakpos = -1;
- else if ((hyperobjects[hyperobjectcount].breakpos = strlen(line1) -(long)(notestart + 7 - buf) + 1) == 0)
+ else if ((hyperobjects[hyperobjectcount].breakpos =
+ strlen(line1)
+ -(long)(notestart + 7 - buf) + 1) == 0)
+ {
hyperobjects[hyperobjectcount].line--;
+ }
}
if (exists_in_tag_table(hyperobjects[hyperobjectcount].node))
{
hyperobjectcount++; /* yep, this was a good hit */
goodHit = 1;
}
- if (!goodHit)
+ if (!goodHit && !hyperobjectcount)
{
- if (!hyperobjectcount)
- {
- xfree(hyperobjects);
- hyperobjects = 0;
- }
+ xfree(hyperobjects);
+ hyperobjects = 0;
}
}
}
- /******************************************************************************
- * Scan for note references of form *
- * "* Comment:[spaces](infofile)reference." *
- ******************************************************************************/
+ /*****************************************************************
+ * Scan for note references of form *
+ * "* Comment:[spaces](infofile)reference." *
+ *****************************************************************/
else if ((tmp = strstr(notestart, ":")) != NULL)
{
char *start = 0, *end = 0, *dot = 0;
dot = finddot(tmp + 1, NOTE_DOT); /* find the trailing dot */
- if (dot != NULL)
- if (dot + 7 < dot + strlen(dot))
- {
- if (strncmp(dot, ".info)", 6) == 0)
- dot = finddot(dot + 1, NOTE_DOT);
- }
- if (((start = strchr(tmp, '(')) != NULL) &&(dot != NULL) &&
- ((end = strchr(start, ')')) != NULL)) /* end may be found only if start is nonNULL!!! */
+ if ( (dot != NULL) && ( dot + 7 < dot + strlen(dot)) )
{
- if (start < dot) /* security mechanism ;) */
+ if (strncmp(dot, ".info)", 6) == 0)
+ dot = finddot(dot + 1, NOTE_DOT);
+ }
+ if ( ((start = strchr(tmp, '(')) != NULL)
+ && (dot != NULL)
+ && ((end = strchr(start, ')')) != NULL))
+ /* end may be found only if start is nonNULL!!! */
+ {
+ if ( (start < dot) && (end < dot) ) /* security mechanism ;) */
{
- if (end < dot) /* security mechanism ;)) */
+ long FilenameLen =(long)(end - start - 1);
+ long NodenameLen =(long)(dot - end - 1);
+ if (!hyperobjectcount)
+ hyperobjects = xmalloc(sizeof(HyperObject));
+ else
{
- long FilenameLen =(long)(end - start - 1);
- long NodenameLen =(long)(dot - end - 1);
- if (!hyperobjectcount)
- hyperobjects = xmalloc(sizeof(HyperObject));
- else
- hyperobjects = xrealloc(hyperobjects, sizeof(HyperObject) *(hyperobjectcount + 1));
- strncpy(hyperobjects[hyperobjectcount].file,
- start + 1, FilenameLen);
- hyperobjects[hyperobjectcount].file[FilenameLen] = 0;
- strncpy(hyperobjects[hyperobjectcount].node,
- end + 1, NodenameLen);
- hyperobjects[hyperobjectcount].node[NodenameLen] = 0;
- hyperobjects[hyperobjectcount].type = 3;
- if (start - buf < strlen(line1))
+ hyperobjects = xrealloc(hyperobjects,
+ sizeof(HyperObject) *(hyperobjectcount + 1));
+ }
+ strncpy(hyperobjects[hyperobjectcount].file,
+ start + 1, FilenameLen);
+ hyperobjects[hyperobjectcount].file[FilenameLen] = 0;
+ strncpy(hyperobjects[hyperobjectcount].node,
+ end + 1, NodenameLen);
+ hyperobjects[hyperobjectcount].node[NodenameLen] = 0;
+ hyperobjects[hyperobjectcount].type = 3;
+ if (start - buf < strlen(line1))
+ {
+ hyperobjects[hyperobjectcount].line = line;
+ hyperobjects[hyperobjectcount].col =
+ calculate_len(buf, start);
+ if (dot - buf < strlen(line1))
{
- hyperobjects[hyperobjectcount].line = line;
- hyperobjects[hyperobjectcount].col = calculate_len(buf, start);
- if (dot - buf < strlen(line1)) /* if the note highlight fits in first line */
- hyperobjects[hyperobjectcount].breakpos = -1; /* we don't need to break highlighting int several lines */
- else
- hyperobjects[hyperobjectcount].breakpos = strlen(line1) -(long)(start - buf); /* otherwise we need it */
+ /* if the note highlight fits in first line
+ * we don't need to break highlighting into
+ * several lines */
+ hyperobjects[hyperobjectcount].breakpos = -1;
}
else
{
- hyperobjects[hyperobjectcount].line = line + 1;
- hyperobjects[hyperobjectcount].col = calculate_len(buf + strlen(line1), start);
- hyperobjects[hyperobjectcount].breakpos = -1;
+ /* otherwise we need it */
+ hyperobjects[hyperobjectcount].breakpos =
+ strlen(line1) -(long)(start - buf);
}
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
- hyperobjectcount++;
}
+ else
+ {
+ hyperobjects[hyperobjectcount].line = line + 1;
+ hyperobjects[hyperobjectcount].col =
+ calculate_len(buf + strlen(line1), start);
+ hyperobjects[hyperobjectcount].breakpos = -1;
+ }
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjectcount++;
}
else
{
@@ -649,7 +716,10 @@
if (!hyperobjectcount)
hyperobjects = xmalloc(sizeof(HyperObject));
else
- hyperobjects = xrealloc(hyperobjects, sizeof(HyperObject) *(hyperobjectcount + 1));
+ {
+ hyperobjects = xrealloc(hyperobjects,
+ sizeof(HyperObject) *(hyperobjectcount + 1));
+ }
start = tmp + 1; /* move after the padding spaces */
while (isspace(*start))
@@ -660,21 +730,34 @@
start, NodenameLen);
hyperobjects[hyperobjectcount].node[NodenameLen] = 0;
hyperobjects[hyperobjectcount].type = 3;
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
if (start - buf < strlen(line1))
{
hyperobjects[hyperobjectcount].line = line;
- hyperobjects[hyperobjectcount].col = calculate_len(buf, start);
- if (dot - buf < strlen(line1)) /* if the note highlight fits in first line */
- hyperobjects[hyperobjectcount].breakpos = -1; /* we don't need to break highlighting int several lines */
+ hyperobjects[hyperobjectcount].col =
+ calculate_len(buf, start);
+ if (dot - buf < strlen(line1))
+ {
+ /* if the note highlight fits in first line
+ * we don't need to break highlighting into
+ * several lines */
+ hyperobjects[hyperobjectcount].breakpos = -1;
+ }
else
- hyperobjects[hyperobjectcount].breakpos = strlen(line1) -(long)(start - buf); /* otherwise we need it */
+ {
+ /* otherwise we need it */
+ hyperobjects[hyperobjectcount].breakpos =
+ strlen(line1) -(long)(start - buf);
+ }
}
else
{
hyperobjects[hyperobjectcount].line = line + 1;
- hyperobjects[hyperobjectcount].col = calculate_len(strlen(line1) + buf, start);
+ hyperobjects[hyperobjectcount].col =
+ calculate_len(strlen(line1) + buf, start);
hyperobjects[hyperobjectcount].breakpos = -1;
}
if (exists_in_tag_table(hyperobjects[hyperobjectcount].node))
@@ -682,13 +765,10 @@
hyperobjectcount++; /* yep, this was a good hit */
goodHit = 1;
}
- if (!goodHit)
+ if (!goodHit && !hyperobjectcount)
{
- if (!hyperobjectcount)
- {
- xfree(hyperobjects);
- hyperobjects = 0;
- }
+ xfree(hyperobjects);
+ hyperobjects = 0;
}
}
}
@@ -719,7 +799,10 @@
if (!hyperobjectcount)
hyperobjects = xmalloc(sizeof(HyperObject));
else
- hyperobjects = xrealloc(hyperobjects, sizeof(HyperObject) *(hyperobjectcount + 1));
+ {
+ hyperobjects = xrealloc(hyperobjects,
+ sizeof(HyperObject) *(hyperobjectcount + 1));
+ }
hyperobjects[hyperobjectcount].line = line;
hyperobjects[hyperobjectcount].col = calculate_len(line1, urlstart);
hyperobjects[hyperobjectcount].breakpos = -1;
@@ -728,8 +811,10 @@
hyperobjects[hyperobjectcount].node[urlend - urlstart] = 0;
strcpy(hyperobjects[hyperobjectcount].file, "");
hyperobjects[hyperobjectcount].tagtableoffset = -1;
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
hyperobjectcount++;
}
/* ftp:// */
@@ -740,7 +825,10 @@
if (!hyperobjectcount)
hyperobjects = xmalloc(sizeof(HyperObject));
else
- hyperobjects = xrealloc(hyperobjects, sizeof(HyperObject) *(hyperobjectcount + 1));
+ {
+ hyperobjects = xrealloc(hyperobjects,
+ sizeof(HyperObject) *(hyperobjectcount + 1));
+ }
hyperobjects[hyperobjectcount].line = line;
hyperobjects[hyperobjectcount].col = calculate_len(line1, urlstart);
hyperobjects[hyperobjectcount].breakpos = -1;
@@ -749,8 +837,10 @@
hyperobjects[hyperobjectcount].node[urlend - urlstart] = 0;
strcpy(hyperobjects[hyperobjectcount].file, "");
hyperobjects[hyperobjectcount].tagtableoffset = -1;
- hyperobjects[hyperobjectcount].nodelen=strlen(hyperobjects[hyperobjectcount].node);
- hyperobjects[hyperobjectcount].filelen=strlen(hyperobjects[hyperobjectcount].file);
+ hyperobjects[hyperobjectcount].nodelen =
+ strlen(hyperobjects[hyperobjectcount].node);
+ hyperobjects[hyperobjectcount].filelen =
+ strlen(hyperobjects[hyperobjectcount].file);
hyperobjectcount++;
}
if (initialhyperobjectcount != hyperobjectcount)
Modified: pinfo/trunk/src/pinfo.c
===================================================================
--- pinfo/trunk/src/pinfo.c 2005-09-08 14:04:14 UTC (rev 214)
+++ pinfo/trunk/src/pinfo.c 2005-09-08 20:33:44 UTC (rev 215)
@@ -381,7 +381,7 @@
/* read the node */
read_item(id, &type, &message, &lines);
- /* handle goto/link where no file was found -- see bellow */
+ /* handle goto/link where no file was found -- see below */
if (!filenotfound)
addinfohistory(curfile, tag_table[tag_table_pos].nodename, -1, -1, -1);
else
More information about the Pinfo-devel
mailing list