summaryrefslogtreecommitdiff
path: root/src/htsfilters.c
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2013-05-14 20:30:28 +0000
committerXavier Roche <xroche@users.noreply.github.com>2013-05-14 20:30:28 +0000
commit07f4b003675260004c49755dde413944a16ca2d3 (patch)
tree11050b4c7fbe1d7c63a38f5f9a6b5ba6d8260ae1 /src/htsfilters.c
parentb09def438c5e47305e4a5ab18d8a646a3b004fdc (diff)
Indenting cleanup for all *.[ch] files, except htsparse.c (too ugly to be automatically indented for now) and /minizip/, /mmsrip/ (external files)
setup: indent -l80 -lc80 -nhnl -nut -bad -bap -bbo -br -brf -bli2 -brs -bls -br -ss -sai -pmt -nsaw -nsaf -nprs -i2 -ce -npsl -npcs -cs -sob -cdw -nbc -lp logs: indent: ./src/htsback.c:157: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:1417: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:1826: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:1833: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:1981: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:2685: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:2747: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:2861: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:3128: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:3512: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htswizard.c:140: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htswizard.c:597: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htswizard.c:598: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htswizard.c:611: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:97: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:106: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:106: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:256: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:262: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:935: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:271: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:272: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:273: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:274: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:275: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:276: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:277: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:278: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:279: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:280: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:281: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:662: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:752: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:413: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:414: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:415: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:416: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:417: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:418: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:419: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:420: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:421: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:422: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:423: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:188: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:507: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:508: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:509: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:510: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:511: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:512: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:580: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:581: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:115: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:246: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:247: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:248: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:249: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:250: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:251: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:314: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:315: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:151: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:158: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:161: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:166: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:174: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:177: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:188: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:243: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:245: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:248: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:257: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:647: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsbauth.c:364: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsbauth.c:387: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htscache.c:473: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsserver.h:112: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsserver.h:187: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsjava.c:312: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsjava.c:379: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsjava.c:407: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsjava.c:472: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsjava.c:483: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htslib.c:593: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:809: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:1743: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:1874: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:1896: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:1984: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2085: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2604: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2605: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2606: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2607: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2608: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2609: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2672: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2673: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2906: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2928: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2996: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:4802: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htslib.c:5353: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5354: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5355: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5357: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5429: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5435: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscore.c:208: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htscore.c:277: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htscore.c:279: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htscore.c:357: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htscore.c:394: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htscore.c:1544: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscore.c:3330: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscore.c:3361: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htshash.c:140: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htshash.c:217: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsname.c:733: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsname.c:749: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsname.c:933: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsname.c:1520: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htszlib.c:76: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htszlib.c:81: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscatchurl.c:268: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsinthash.c:156: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:159: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:176: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:179: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:226: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:253: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsftp.c:169: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsftp.c:177: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsfilters.c:67: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsfilters.c:80: Warning:old style assignment ambiguity in "=*". Assuming "= *"
Diffstat (limited to 'src/htsfilters.c')
-rw-r--r--src/htsfilters.c294
1 files changed, 157 insertions, 137 deletions
diff --git a/src/htsfilters.c b/src/htsfilters.c
index 4cc740b..d7b6737 100644
--- a/src/htsfilters.c
+++ b/src/htsfilters.c
@@ -17,18 +17,15 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
Important notes:
- We hereby ask people using this source NOT to use it in purpose of grabbing
emails addresses, or collecting any other private information on persons.
This would disgrace our work, and spoil the many hours we spent on it.
-
Please visit our Website: http://www.httrack.com
*/
-
/* ------------------------------------------------------------ */
/* File: httrack.c subroutines: */
/* filters ("regexp") */
@@ -38,7 +35,6 @@ Please visit our Website: http://www.httrack.com
/* Internal engine bytecode */
#define HTS_INTERNAL_BYTECODE
-
// *.gif match all gif files
// *[file]/*[file].exe match all exe files with one folder structure
// *[A-Z,a-z,0-9,/,?] match letters, nums, / and ?
@@ -59,43 +55,45 @@ Please visit our Website: http://www.httrack.com
// optionnel: taille à contrôller (ou numéro, etc) en pointeur
// (en de détection de *size, la taille limite est écrite par dessus *size)
// exemple: +-*.gif*[<5] == supprimer GIF si <5KB
-int fa_strjoker(int type,char** filters,int nfil,char* nom,LLint* size,int* size_flag,int* depth) {
- int verdict = 0; // on sait pas
+int fa_strjoker(int type, char **filters, int nfil, char *nom, LLint * size,
+ int *size_flag, int *depth) {
+ int verdict = 0; // on sait pas
int i;
- LLint sizelimit=0;
+ LLint sizelimit = 0;
+
if (size)
- sizelimit=*size;
- for(i=0;i<nfil;i++) {
+ sizelimit = *size;
+ for(i = 0; i < nfil; i++) {
LLint sz;
int filteroffs = 1;
+
if (strncmp(filters[i] + filteroffs, "mime:", 5) == 0) {
- if (type == 0) // regular filters
+ if (type == 0) // regular filters
continue;
- filteroffs += 5; // +mime:text/html
- } else { // mime filters
+ filteroffs += 5; // +mime:text/html
+ } else { // mime filters
if (type != 0)
continue;
}
if (size)
- sz=*size;
- if (strjoker(nom, filters[i] + filteroffs, &sz, size_flag)) { // reconnu
+ sz = *size;
+ if (strjoker(nom, filters[i] + filteroffs, &sz, size_flag)) { // reconnu
if (size)
- if (sz != *size)
- sizelimit=sz;
- if (filters[i][0]=='+')
- verdict = 1; // autorisé
+ if (sz != *size)
+ sizelimit = sz;
+ if (filters[i][0] == '+')
+ verdict = 1; // autorisé
else
- verdict = -1; // interdit
+ verdict = -1; // interdit
if (depth)
- *depth=i;
+ *depth = i;
}
}
if (size)
- *size=sizelimit;
+ *size = sizelimit;
return verdict;
}
-
// supercomparateur joker (tm)
// compare a et b (b=avec joker dedans), case insensitive [voir CI]
// renvoi l'adresse de la première lettre de la chaine
@@ -104,211 +102,232 @@ int fa_strjoker(int type,char** filters,int nfil,char* nom,LLint* size,int* size
// cet algo est 'un peu' récursif mais ne consomme pas trop de tm
// * = toute lettre
// --?-- : spécifique à HTTrack et aux ?
-HTS_INLINE char* strjoker(char* chaine,char* joker,LLint* size,int* size_flag) {
+HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size,
+ int *size_flag) {
//int err=0;
- if (strnotempty(joker)==0) { // fin de chaine joker
- if (strnotempty(chaine)==0) // fin aussi pour la chaine: ok
+ if (strnotempty(joker) == 0) { // fin de chaine joker
+ if (strnotempty(chaine) == 0) // fin aussi pour la chaine: ok
return chaine;
- else if (chaine[0]=='?')
- return chaine; // --?-- pour les index.html?Choix=2
+ else if (chaine[0] == '?')
+ return chaine; // --?-- pour les index.html?Choix=2
else
- return NULL; // non trouvé
+ return NULL; // non trouvé
}
-
// on va progresser en suivant les 'mots' contenus dans le joker
// un mot peut être un * ou bien toute autre séquence de lettres
-
- if (strcmp(joker,"*")==0) { // ok, rien après
+
+ if (strcmp(joker, "*") == 0) { // ok, rien après
return chaine;
}
-
// 1er cas: jokers * ou jokers multiples *[..]
- if (joker[0]=='*') { // comparer joker+reste (*toto/..)
- int jmp; // nombre de caractères pour le prochain mot dans joker
- int cut = 0; // interdire tout caractère superflu
+ if (joker[0] == '*') { // comparer joker+reste (*toto/..)
+ int jmp; // nombre de caractères pour le prochain mot dans joker
+ int cut = 0; // interdire tout caractère superflu
char pass[256];
- char LEFT='[',RIGHT=']';
- int unique=0;
-
- switch(joker[1]) {
- case '[':
- LEFT='[';
- RIGHT=']';
- unique=0;
+ char LEFT = '[', RIGHT = ']';
+ int unique = 0;
+
+ switch (joker[1]) {
+ case '[':
+ LEFT = '[';
+ RIGHT = ']';
+ unique = 0;
break;
- case '(':
- LEFT='(';
- RIGHT=')';
- unique=1;
+ case '(':
+ LEFT = '(';
+ RIGHT = ')';
+ unique = 1;
break;
}
- if ((joker[1]==LEFT) && (joker[2]!=LEFT)) { // multijoker (tm)
+ if ((joker[1] == LEFT) && (joker[2] != LEFT)) { // multijoker (tm)
int i;
- for(i=0;i<256;i++) pass[i]=0;
+
+ for(i = 0; i < 256; i++)
+ pass[i] = 0;
// noms réservés
- if ((strfield(joker+2,"file")) || (strfield(joker+2,"name"))) {
- for(i=0;i<256;i++) pass[i]=1;
+ if ((strfield(joker + 2, "file")) || (strfield(joker + 2, "name"))) {
+ for(i = 0; i < 256; i++)
+ pass[i] = 1;
pass[(int) '?'] = 0;
//pass[(int) ';'] = 0;
pass[(int) '/'] = 0;
- i=2;
- { int len=(int) strlen(joker);
- while ((joker[i]!=RIGHT) && (joker[i]) && (i<len)) i++;
+ i = 2;
+ {
+ int len = (int) strlen(joker);
+
+ while((joker[i] != RIGHT) && (joker[i]) && (i < len))
+ i++;
}
- } else if (strfield(joker+2,"path")) {
- for(i=0;i<256;i++) pass[i]=1;
+ } else if (strfield(joker + 2, "path")) {
+ for(i = 0; i < 256; i++)
+ pass[i] = 1;
pass[(int) '?'] = 0;
//pass[(int) ';'] = 0;
- i=2;
- { int len=(int) strlen(joker);
- while ((joker[i]!=RIGHT) && (joker[i]) && (i<len)) i++;
+ i = 2;
+ {
+ int len = (int) strlen(joker);
+
+ while((joker[i] != RIGHT) && (joker[i]) && (i < len))
+ i++;
}
- } else if (strfield(joker+2,"param")) {
- if (chaine[0]=='?') { // il y a un paramètre juste là
- for(i=0;i<256;i++) pass[i]=1;
- } // sinon synonyme de 'rien'
- i=2;
- { int len=(int) strlen(joker);
- while ((joker[i]!=RIGHT) && (joker[i]) && (i<len)) i++;
+ } else if (strfield(joker + 2, "param")) {
+ if (chaine[0] == '?') { // il y a un paramètre juste là
+ for(i = 0; i < 256; i++)
+ pass[i] = 1;
+ } // sinon synonyme de 'rien'
+ i = 2;
+ {
+ int len = (int) strlen(joker);
+
+ while((joker[i] != RIGHT) && (joker[i]) && (i < len))
+ i++;
}
} else {
// décode les directives comme *[A-Z,âêîôû,0-9]
- i=2;
- if (joker[i] == RIGHT) { // *[] signifie "plus rien après"
- cut = 1; // caractère supplémentaire interdit
+ i = 2;
+ if (joker[i] == RIGHT) { // *[] signifie "plus rien après"
+ cut = 1; // caractère supplémentaire interdit
} else {
- int len=(int) strlen(joker);
- while ((joker[i]!=RIGHT) && (joker[i]) && (i<len)) {
- if ( (joker[i]=='<') || (joker[i]=='>') ) { // *[<10]
- int lsize=0;
+ int len = (int) strlen(joker);
+
+ while((joker[i] != RIGHT) && (joker[i]) && (i < len)) {
+ if ((joker[i] == '<') || (joker[i] == '>')) { // *[<10]
+ int lsize = 0;
int lverdict;
+
i++;
- if (sscanf(joker+i,"%d",&lsize) == 1) {
+ if (sscanf(joker + i, "%d", &lsize) == 1) {
if (size) {
- if (*size>=0) {
+ if (*size >= 0) {
if (size_flag)
- *size_flag=1; /* a joué */
- if (joker[i-1]=='<')
- lverdict=(*size<lsize);
+ *size_flag = 1; /* a joué */
+ if (joker[i - 1] == '<')
+ lverdict = (*size < lsize);
else
- lverdict=(*size>lsize);
+ lverdict = (*size > lsize);
if (!lverdict) {
- return NULL; // ne correspond pas
+ return NULL; // ne correspond pas
} else {
- *size=lsize;
- return chaine; // ok
+ *size = lsize;
+ return chaine; // ok
}
} else
- return NULL; // ne correspond pas
+ return NULL; // ne correspond pas
} else
- return NULL; // ne correspond pas (test impossible)
+ return NULL; // ne correspond pas (test impossible)
// jump
- while(isdigit((unsigned char)joker[i])) i++;
+ while(isdigit((unsigned char) joker[i]))
+ i++;
}
- }
- else if (joker[i+1]=='-') { // 2 car, ex: *[A-Z]
- if ((int) (unsigned char) joker[i+2]>(int) (unsigned char) joker[i]) {
+ } else if (joker[i + 1] == '-') { // 2 car, ex: *[A-Z]
+ if ((int) (unsigned char) joker[i + 2] >
+ (int) (unsigned char) joker[i]) {
int j;
- for(j=(int) (unsigned char) joker[i];j<=(int) (unsigned char) joker[i+2];j++)
- pass[j]=1;
-
+
+ for(j = (int) (unsigned char) joker[i];
+ j <= (int) (unsigned char) joker[i + 2]; j++)
+ pass[j] = 1;
+
}
// else err=1;
- i+=3;
+ i += 3;
} else { // 1 car, ex: *[ ]
- if (joker[i+2]=='\\' && joker[i+3] != 0) { // escaped char, such as *[\[] or *[\]]
+ if (joker[i + 2] == '\\' && joker[i + 3] != 0) { // escaped char, such as *[\[] or *[\]]
i++;
}
- pass[(int) (unsigned char) joker[i]]=1;
+ pass[(int) (unsigned char) joker[i]] = 1;
i++;
}
- if ((joker[i]==',') || (joker[i]==';')) i++;
+ if ((joker[i] == ',') || (joker[i] == ';'))
+ i++;
}
}
}
// à sauter dans joker
- jmp=i;
- if (joker[i]) jmp++;
-
+ jmp = i;
+ if (joker[i])
+ jmp++;
+
//
- } else { // tout autoriser
+ } else { // tout autoriser
//
int i;
- for(i=0;i<256;i++) pass[i]=1; // tout autoriser
- jmp=1;
+
+ for(i = 0; i < 256; i++)
+ pass[i] = 1; // tout autoriser
+ jmp = 1;
////if (joker[2]==LEFT) jmp=3; // permet de recher *<crochet ouvrant>
}
-
+
{
- int i,max;
- char* adr;
+ int i, max;
+ char *adr;
// la chaine doit se terminer exactement
if (cut) {
if (strnotempty(chaine))
- return NULL; // perdu
+ return NULL; // perdu
else
- return chaine; // ok
+ return chaine; // ok
}
-
// comparaison en boucle, c'est ca qui consomme huhu..
// le tableau pass[256] indique les caractères ASCII autorisés
// tester sans le joker (pas ()+ mais ()*)
if (!unique) {
- if ( (adr=strjoker(chaine,joker+jmp,size,size_flag)) ) {
+ if ((adr = strjoker(chaine, joker + jmp, size, size_flag))) {
return adr;
}
}
-
// tester
- i=0;
+ i = 0;
if (!unique)
max = (int) strlen(chaine);
- else /* *(a) only match a (not aaaaa) */
- max=1;
- while(i<(int) max) {
- if (pass[(int) (unsigned char) chaine[i]]) { // caractère autorisé
- if ( (adr=strjoker(chaine+i+1,joker+jmp,size,size_flag)) ) {
+ else /* *(a) only match a (not aaaaa) */
+ max = 1;
+ while(i < (int) max) {
+ if (pass[(int) (unsigned char) chaine[i]]) { // caractère autorisé
+ if ((adr = strjoker(chaine + i + 1, joker + jmp, size, size_flag))) {
return adr;
}
i++;
- } else i=max+2; // sortir
+ } else
+ i = max + 2; // sortir
}
// tester chaîne vide
- if (i!=max+2) // avant c'est ok
- if ( (adr=strjoker(chaine+max,joker+jmp,size,size_flag)) )
- return adr;
-
- return NULL; // perdu
+ if (i != max + 2) // avant c'est ok
+ if ((adr = strjoker(chaine + max, joker + jmp, size, size_flag)))
+ return adr;
+
+ return NULL; // perdu
}
- } else { // comparer mot+reste (toto*..)
+ } else { // comparer mot+reste (toto*..)
if (strnotempty(chaine)) {
- int jmp=0,ok=1;
-
+ int jmp = 0, ok = 1;
+
// comparer début de joker et début de chaine
- while((joker[jmp]!='*') && (joker[jmp]) && (ok)) {
+ while((joker[jmp] != '*') && (joker[jmp]) && (ok)) {
// CI : remplacer streql par une comparaison !=
- if (!streql(chaine[jmp],joker[jmp])) {
- ok=0; // quitter
+ if (!streql(chaine[jmp], joker[jmp])) {
+ ok = 0; // quitter
}
jmp++;
}
-
+
// comparaison ok?
if (ok) {
// continuer la comparaison.
- if (strjoker(chaine+jmp,joker+jmp,size,size_flag))
- return chaine; // retourner 1e lettre
+ if (strjoker(chaine + jmp, joker + jmp, size, size_flag))
+ return chaine; // retourner 1e lettre
}
-
- } // strlen(a)
- return NULL;
- } // * ou mot
+
+ } // strlen(a)
+ return NULL;
+ } // * ou mot
return NULL;
}
@@ -317,10 +336,11 @@ HTS_INLINE char* strjoker(char* chaine,char* joker,LLint* size,int* size_flag) {
// exemple: find dans un texte de strcpybuff(*[A-Z,a-z],"*[0-9]"); va rechercher la première occurence
// d'un strcpy sur une variable ayant un nom en lettres et copiant une chaine de chiffres
// ATTENTION!! Eviter les jokers en début, où gare au temps machine!
-char* strjokerfind(char* chaine,char* joker) {
- char* adr;
+char *strjokerfind(char *chaine, char *joker) {
+ char *adr;
+
while(*chaine) {
- if ( (adr=strjoker(chaine,joker,NULL,NULL)) ) { // ok trouvé
+ if ((adr = strjoker(chaine, joker, NULL, NULL))) { // ok trouvé
return adr;
}
chaine++;