Overview
SHA1 Hash: | 8f423ad438265edb43a2e014e4901123bd0930bc |
---|---|
Date: | 2007-10-21 11:11:02 |
User: | drh |
Comment: | Fix a bug in wiki rendering that caused an extra paragraph end tag following a hyperlink. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/tkt.c from [0661d23511] to [5149f78c34].
@@ -52,10 +52,19 @@ ** here. */ static int nField = 0; static Blob fieldList; static char **azField = 0; +static char **azValue = 0; +static unsigned char *aChanged = 0; + +/* +** Compare two entries in azField for sorting purposes +*/ +static int nameCmpr(void *a, void *b){ + return strcmp((char*)a, (char*)b); +} /* ** Subscript command: LIST setfields ** ** Parse up the list and populate the nField and azField variables. @@ -70,19 +79,83 @@ zFieldList = SbS_StackValue(p, 0, &nFieldList); blob_appendf(&fieldList, zFieldList, nFieldList); while( blob_token(&fieldList, &field) ){ nField++; } - azField = malloc( sizeof(azField[0])*nField ); - blob_rewind(&fieldList); - i = 0; - while( blob_token(&fieldList, &field) ){ - azField[i] = blob_terminate(&field); + azField = malloc( sizeof(azField[0])*nField*2 + nField ); + if( azField ){ + azValue = &azField[nField]; + aChanged = (unsigned char*)&azValue[nField]; + blob_rewind(&fieldList); + i = 0; + while( blob_token(&fieldList, &field) ){ + azField[i] = blob_terminate(&field); + azValue[i] = 0; + aChanged[i] = 0; + } } + qsort(azField, nField, sizeof(azField[0]), nameCmpr); } SbS_Pop(p, 1); return 0; +} + +/* +** Find the text of the field whose name is the Nth element down +** on the Subscript stack. 0 means the top of the stack. +** +** First check for a value for this field as passed in via +** CGI parameter. If not found, then use the value from the +** database. +*/ +static const char *field_value(int N){ + const char *zFName; + int nFName; + char *zName; + int i; + const char *zValue; + + zFName = SbS_StackValue(pInterp, N, &nFName); + if( zField==0 ){ + return 0; + } + zName = mprintf("%.*s", nFName, zFName); + zValue = P(zName); + if( zValue==0 ){ + for(i=0; i<nField; i++){ + if( strcmp(azField[i], zName)==0 ){ + zValue = azValue[i]; + break; + } + } + } + free(zName); + return zValue; +} + +/* +** Fill in the azValue[] array with the contents of the ticket +** table for the entry determined by the "name" CGI parameter. +*/ +static void fetchOriginalValues(void){ + Blob sql; + Stmt q; + int i; + char *zSep = "SELECT "; + blob_zero(&sql); + for(i=0; i<nField; i++){ + blob_appendf(&sql, "%s%s", zSep, azField[i]); + zSep = ", "; + } + blob_appendf(" FROM ticket WHERE uuid=%Q", PD("name","")); + db_prepare(&q, "%b", &sql); + if( db_step(&q)==SQLITE_ROW ){ + for(i=0; i<nField; i++){ + azValue[i] = db_column_malloc(&q, i); + } + } + db_finalize(&q); } /* ** Subscript command: INTEGER not INTEGER */
Modified src/wikiformat.c from [a1f06c841d] to [aab9e4b700].
@@ -1007,11 +1007,10 @@ break; } } z += n; } - endAutoParagraph(p); } /* ** Transform the text in the pIn blob. Write the results @@ -1033,10 +1032,11 @@ renderer.pOut = cgi_output_blob(); } z = blob_str(pIn); wiki_render(&renderer, z); + endAutoParagraph(&renderer); while( renderer.nStack ){ popStack(&renderer); } blob_append(renderer.pOut, "\n", 1); free(renderer.aStack);