From 5f2139215fe27765889507aa4dd938a5c6e68ea7 Mon Sep 17 00:00:00 2001 From: zzo38 Date: Tue, 29 Mar 2011 17:13:42 -0700 Subject: [PATCH] Name sorting --- system/plain.cards | 8 ++++++-- texnicard.w | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/system/plain.cards b/system/plain.cards index fc8e3ce..7b790dc 100755 --- a/system/plain.cards +++ b/system/plain.cards @@ -651,6 +651,10 @@ card lists and compared. A conversion table \.n is used to change any parentheses that might be inside the text into control characters and back again, since parentheses are not allowed in any register names. +Each such name will begin with an asterisk (which is automatically added +and removed as necessary). This is so that it will not interfere with +existing names for commands and so on. + These registers also have a value, although the present program does not use it. You might find a use for it in your own templates, though. @@ -660,11 +664,11 @@ use it. You might find a use for it in your own templates, though. @S Name_To_Text @. ( name -- text ) -N`n(Translate)x +NAD`n(Translate)x @S Text_To_Name @. ( text -- name ) -`n(Translate)x[)]+[(]r+x +`n(Translate)x[)]+[(*]r+x @. --- Statistics --- diff --git a/texnicard.w b/texnicard.w index 6fa8e30..92d5f11 100755 --- a/texnicard.w +++ b/texnicard.w @@ -1850,8 +1850,10 @@ other values, which are described a bit later.) @d no_sort 0 @d primary_ascending 'A' @d primary_descending 'Z' +@d primary_name 'N' @d secondary_ascending 'a' @d secondary_descending 'z' +@d secondary_name 'n' @d record_sorted_position 'R' @d reset_high_bits 'q' @# @@ -1873,6 +1875,8 @@ other values, which are described a bit later.) return (p1s->field[i]>p2s->field[i])?1:-1; } @+else if(G_table(i)==primary_descending) { return (p1s->field[i]field[i])?1:-1; + } @+else if(G_table(i)==primary_name) { + return name_compare(p1s->field[i],p2s->field[i]); } } for(i=0;i<32;i++) if(p1s->field[i]!=p2s->field[i]) { @@ -1880,6 +1884,8 @@ other values, which are described a bit later.) return (p1s->field[i]>p2s->field[i])?1:-1; } @+else if(G_table(i)==secondary_descending) { return (p1s->field[i]field[i])?1:-1; + } @+else if(G_table(i)==secondary_name) { + return name_compare(p1s->field[i],p2s->field[i]); } } } @@ -2166,6 +2172,42 @@ is lesser since it has no fractional part to make it greater). if(a!=b) return (a; + @; + @; + } + return (n1= { + while(a @^spider@> -- 2.11.4.GIT