Fossil

Check-in [a4d57c6b26]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Factor the code that outputs line-numbered text into a separate subroutine, for clarity of presentation.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a4d57c6b261abe4992e7a9aea6ba1c180c071988
User & Date: drh 2011-02-21 18:20:53.033
Context
2011-02-21
22:26
Added a few more external links to the "Reviews" page. ... (check-in: 184500e46a user: drh tags: trunk)
18:20
Factor the code that outputs line-numbered text into a separate subroutine, for clarity of presentation. ... (check-in: a4d57c6b26 user: drh tags: trunk)
16:33
Add the ability to use a graphical merging tool to resolve merge conflicts. Even without a configured graphical tool, leave files behind (VCS droppings) that contain the baseline, original, and merged files. ... (check-in: 9b7a6f80b2 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/info.c.
1111
1112
1113
1114
1115
1116
1117




























































1118
1119
1120
1121
1122
1123
1124
      manifest_destroy(pManifest);
      return rid;
    }
  }
  return 0;
}






























































/*
** WEBPAGE: artifact
** URL: /artifact?name=ARTIFACTID
** URL: /artifact?ci=CHECKIN&filename=PATH
** 
** Show the complete content of a file identified by ARTIFACTID







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
      manifest_destroy(pManifest);
      return rid;
    }
  }
  return 0;
}

/*
** The "z" argument is a string that contains the text of a source code
** file.  This routine appends that text to the HTTP reply with line numbering.
**
** zLn is the ?ln= parameter for the HTTP query.  If there is an argument,
** then highlight that line number and scroll to it once the page loads.
** If there are two line numbers, highlight the range of lines.
*/
static void output_text_with_line_numbers(
  const char *z,
  const char *zLn
){
  int iStart, iEnd;    /* Start and end of region to highlight */
  int n = 0;           /* Current line number */
  int i;               /* Loop index */
  int iTop = 0;        /* Scroll so that this line is on top of screen. */

  iStart = iEnd = atoi(zLn);
  if( iStart>0 ){
    for(i=0; fossil_isdigit(zLn[i]); i++){}
    if( zLn[i]==',' || zLn[i]=='-' || zLn[i]=='.' ){
      i++;
      while( zLn[i]=='.' ){ i++; }
      iEnd = atoi(&zLn[i]);
    }
    if( iEnd<iStart ) iEnd = iStart;
    iTop = iStart - 15 + (iEnd-iStart)/4;
    if( iTop>iStart - 2 ) iTop = iStart-2;
  }
  @ <pre>
  while( z[0] ){
    n++;
    for(i=0; z[i] && z[i]!='\n'; i++){}
    if( n==iTop ) cgi_append_content("<span id=\"topln\">", -1);
    if( n==iStart ){
      cgi_append_content("<div class=\"selectedText\">",-1);
    }
    cgi_printf("%6d  ", n);
    if( i>0 ){
      char *zHtml = htmlize(z, i);
      cgi_append_content(zHtml, -1);
      fossil_free(zHtml);
    }
    if( n==iStart-15 ) cgi_append_content("</span>", -1);
    if( n==iEnd ) cgi_append_content("</div>", -1);
    else cgi_append_content("\n", 1);
    z += i;
    if( z[0]=='\n' ) z++;
  }
  if( n<iEnd ) cgi_printf("</div>");
  @ </pre>
  if( iStart ){
    @ <script type="text/JavaScript">
    @ /* <![CDATA[ */
    @ document.getElementById('topln').scrollIntoView(true);
    @ /* ]]> */
    @ </script>
  }
}


/*
** WEBPAGE: artifact
** URL: /artifact?name=ARTIFACTID
** URL: /artifact?ci=CHECKIN&filename=PATH
** 
** Show the complete content of a file identified by ARTIFACTID
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
    style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
    zMime = mimetype_from_content(&content);
    @ <blockquote>
    if( zMime==0 ){
      const char *zLn = P("ln");
      const char *z = blob_str(&content);
      if( zLn ){
        int iStart, iEnd;
        int n = 0;
        int i;
        iStart = iEnd = atoi(zLn);
        if( iStart>0 ){
          for(i=0; zLn[i] && zLn[i]!=','; i++){}
          if( zLn[i] ) iEnd = atoi(&zLn[i+1]);
          if( iEnd<iStart ) iEnd = iStart;
        }
        @ <pre>
        while( z[0] ){
          n++;
          for(i=0; z[i] && z[i]!='\n'; i++){}
          if( n==iStart-15 ) cgi_append_content("<span id=\"topln\">", -1);
          if( n==iStart ){
            cgi_append_content("<div class=\"selectedText\">",-1);
          }
          cgi_printf("%06d  ", n);
          if( i>0 ){
            char *zHtml = htmlize(z, i);
            cgi_append_content(zHtml, -1);
            fossil_free(zHtml);
          }
          if( n==iStart-15 ) cgi_append_content("</span>", -1);
          if( n==iEnd ) cgi_append_content("</div>", -1);
          else cgi_append_content("\n", 1);
          z += i;
          if( z[0]=='\n' ) z++;
        }
        if( n<iEnd ) cgi_printf("</div>");
        @ </pre>
        if( iStart ){
          @ <script type="text/JavaScript">
          @ /* <![CDATA[ */
          @ document.getElementById('topln').scrollIntoView(true);
          @ /* ]]> */
          @ </script>
        }
      }else{
        @ <pre>
        @ %h(z);
        @ </pre>
      }
    }else if( strncmp(zMime, "image/", 6)==0 ){
      @ <img src="%s(g.zTop)/raw?name=%s(zUuid)&amp;m=%s(zMime)"></img>







<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1255
1256
1257
1258
1259
1260
1261



1262


































1263
1264
1265
1266
1267
1268
1269
    style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
    zMime = mimetype_from_content(&content);
    @ <blockquote>
    if( zMime==0 ){
      const char *zLn = P("ln");
      const char *z = blob_str(&content);
      if( zLn ){



        output_text_with_line_numbers(z, zLn);


































      }else{
        @ <pre>
        @ %h(z);
        @ </pre>
      }
    }else if( strncmp(zMime, "image/", 6)==0 ){
      @ <img src="%s(g.zTop)/raw?name=%s(zUuid)&amp;m=%s(zMime)"></img>