diff options
Diffstat (limited to 'src/ops/nnstyle.h')
| -rw-r--r-- | src/ops/nnstyle.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/ops/nnstyle.h b/src/ops/nnstyle.h new file mode 100644 index 0000000..4b8be5e --- /dev/null +++ b/src/ops/nnstyle.h | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /************************************************************************* | ||
| 2 | * | ||
| 3 | * HTCd - Copyright (C) 1998-2006 Henrik Rydberg | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef NNSTYLEH | ||
| 21 | #define NNSTYLEH | ||
| 22 | |||
| 23 | #include <mt/split.h> | ||
| 24 | |||
| 25 | const charset cset_wsdot=cset_ws|'.'; | ||
| 26 | |||
| 27 | inline mstring nncase(const sref& b) | ||
| 28 | { | ||
| 29 | static const mstring comma_tag(","),and_tag("and"); | ||
| 30 | mstring acc,a,name; | ||
| 31 | sref next,first,rest=b; | ||
| 32 | while(Split(first,rest,cset_wsdot)) { | ||
| 33 | if(first==comma_tag||eqn(first,and_tag)) continue; | ||
| 34 | (name=first.left_first(comma_tag)).tosim(); | ||
| 35 | name[0]=cset_ucase[name[0]]; | ||
| 36 | next=First(rest); | ||
| 37 | if(first.back()==','||next.empty()||*next==','||eqn(next,and_tag)) { | ||
| 38 | a.insert(0,name); | ||
| 39 | if(acc.nempty()) { acc+=' '; acc+=and_tag; acc+=' '; } | ||
| 40 | acc+=a; | ||
| 41 | a.clear(); | ||
| 42 | } | ||
| 43 | else { a+=' '; a+=name[0]; a+='.'; } | ||
| 44 | } | ||
| 45 | return acc; | ||
| 46 | } | ||
| 47 | |||
| 48 | inline int nncomp(const sref& L,const sref& R) | ||
| 49 | { | ||
| 50 | return nncase(L).compare(nncase(R)); | ||
| 51 | } | ||
| 52 | |||
| 53 | #endif | ||
