Click here to Skip to main content
16,016,882 members
Home / Discussions / C#
   

C#

 
AnswerRe: How Can I Use Visual Studio Code Editor? Pin
leppie3-Sep-05 2:13
leppie3-Sep-05 2:13 
QuestionHow to Develope Independent Clock Pin
Suseel kumar P2-Sep-05 21:42
Suseel kumar P2-Sep-05 21:42 
AnswerRe: How to Develope Independent Clock Pin
Libor Tinka3-Sep-05 0:14
Libor Tinka3-Sep-05 0:14 
QuestionSystem.Type --> Instance Pin
peterchen2-Sep-05 21:42
peterchen2-Sep-05 21:42 
AnswerRe: System.Type --> Instance Pin
Anonymous3-Sep-05 2:15
Anonymous3-Sep-05 2:15 
AnswerRe: System.Type --> Instance Pin
Anonymous3-Sep-05 2:15
Anonymous3-Sep-05 2:15 
AnswerRe: System.Type --> Instance Pin
leppie3-Sep-05 2:16
leppie3-Sep-05 2:16 
Questioncan anyone convert this to C# Pin
Mridang Agarwalla2-Sep-05 21:41
Mridang Agarwalla2-Sep-05 21:41 
00001 /*  $Revision: 1.2 $<br />
00002 **<br />
00003 **  Do shell-style pattern matching for ?, \, [], and * characters.<br />
00004 **  Might not be robust in face of malformed patterns; e.g., "foo[a-"<br />
00005 **  could cause a segmentation violation.  It is 8bit clean.<br />
00006 **<br />
00007 **  Written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986.<br />
00008 **  Rich $alz is now <rsalz@osf.org>.<br />
00009 **  April, 1991:  Replaced mutually-recursive calls with in-line code<br />
00010 **  for the star character.<br />
00011 **<br />
00012 **  Special thanks to Lars Mathiesen <thorinn@diku.dk> for the ABORT code.<br />
00013 **  This can greatly speed up failing wildcard patterns.  For example:<br />
00014 **      pattern: -*-*-*-*-*-*-12-*-*-*-m-*-*-*<br />
00015 **      text 1:  -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1<br />
00016 **      text 2:  -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1<br />
00017 **  Text 1 matches with 51 calls, while text 2 fails with 54 calls.  Without<br />
00018 **  the ABORT code, it takes 22310 calls to fail.  Ugh.  The following<br />
00019 **  explanation is from Lars:<br />
00020 **  The precondition that must be fulfilled is that DoMatch will consume<br />
00021 **  at least one character in text.  This is true if *p is neither '*' nor<br />
00022 **  '\0'.)  The last return has ABORT instead of FALSE to avoid quadratic<br />
00023 **  behaviour in cases like pattern "*a*b*c*d" with text "abcxxxxx".  With<br />
00024 **  FALSE, each star-loop has to run to the end of the text; with ABORT<br />
00025 **  only the last one does.<br />
00026 **<br />
00027 **  Once the control of one instance of DoMatch enters the star-loop, that<br />
00028 **  instance will return either TRUE or ABORT, and any calling instance<br />
00029 **  will therefore return immediately after (without calling recursively<br />
00030 **  again).  In effect, only one star-loop is ever active.  It would be<br />
00031 **  possible to modify the code to maintain this context explicitly,<br />
00032 **  eliminating all recursive calls at the cost of some complication and<br />
00033 **  loss of clarity (and the ABORT stuff seems to be unclear enough by<br />
00034 **  itself).  I think it would be unwise to try to get this into a<br />
00035 **  released version unless you have a good test data base to try it out<br />
00036 **  on.<br />
00037 */<br />
00038 #include <stdio.h><br />
00039 #include <sys/types.h><br />
00040 //#include "configdata.h"<br />
00041 //#include "clibrary.h"<br />
00042 #include "wildmat.h"<br />
00043 <br />
00044 <br />
00045 #define TRUE                    1<br />
00046 #define FALSE                   0<br />
00047 #define ABORT                   -1<br />
00048 <br />
00049 <br />
00050     /* What character marks an inverted character class? */<br />
00051 #define NEGATE_CLASS            '^'<br />
00052     /* Is "*" a common pattern? */<br />
00053 #define OPTIMIZE_JUST_STAR<br />
00054     /* Do tar(1) matching rules, which ignore a trailing slash? */<br />
00055 #undef MATCH_TAR_PATTERN<br />
00056 <br />
00057 <br />
00058 /*<br />
00059 **  Match text and p, return TRUE, FALSE, or ABORT.<br />
00060 */<br />
00061 static int DoMatch(text, p)<br />
00062 register char *text;<br />
00063 register char *p;<br />
00064 {<br />
00065         register int last;<br />
00066         register int matched;<br />
00067         register int reverse;<br />
00068 <br />
00069         for (; *p; text++, p++) {<br />
00070                 if (*text == '\0' && *p != '*')<br />
00071                         return ABORT;<br />
00072                 switch (*p) {<br />
00073                 case '\\':<br />
00074                         /* Literal match with following character. */<br />
00075                         p++;<br />
00076                         /* FALLTHROUGH */<br />
00077                 default:<br />
00078                         if (*text != *p)<br />
00079                                 return FALSE;<br />
00080                         continue;<br />
00081                 case '?':<br />
00082                         /* Match anything. */<br />
00083                         continue;<br />
00084                 case '*':<br />
00085                         while (*++p == '*')<br />
00086                                 /* Consecutive stars act just like one. */<br />
00087                                 continue;<br />
00088                         if (*p == '\0')<br />
00089                                 /* Trailing star matches everything. */<br />
00090                                 return TRUE;<br />
00091                         while (*text)<br />
00092                                 if ((matched =<br />
00093                                      DoMatch(text++, p)) != FALSE)<br />
00094                                         return matched;<br />
00095                         return ABORT;<br />
00096                 case '[':<br />
00097                         reverse = p[1] == NEGATE_CLASS ? TRUE : FALSE;<br />
00098                         if (reverse)<br />
00099                                 /* Inverted character class. */<br />
00100                                 p++;<br />
00101                         matched = FALSE;<br />
00102                         if (p[1] == ']' || p[1] == '-')<br />
00103                                 if (*++p == *text)<br />
00104                                         matched = TRUE;<br />
00105                         for (last = *p; *++p && *p != ']'; last = *p)<br />
00106                                 /* This next line requires a good C compiler. */<br />
00107                                 if (*p == '-' && p[1] != ']'<br />
00108                                     ? *text <= *++p<br />
00109                                     && *text >= last : *text == *p)<br />
00110                                         matched = TRUE;<br />
00111                         if (matched == reverse)<br />
00112                                 return FALSE;<br />
00113                         continue;<br />
00114                 }<br />
00115         }<br />
00116 <br />
00117 #ifdef  MATCH_TAR_PATTERN<br />
00118         if (*text == '/')<br />
00119                 return TRUE;<br />
00120 #endif                          /* MATCH_TAR_ATTERN */<br />
00121         return *text == '\0';<br />
00122 }<br />
00123 <br />
00124 <br />
00125 /*<br />
00126 **  User-level routine.  Returns TRUE or FALSE.<br />
00127 */<br />
00128 int wildmat(const char *text, const char *p)<br />
00129 {<br />
00130 #ifdef  OPTIMIZE_JUST_STAR<br />
00131         if (p[0] == '*' && p[1] == '\0')<br />
00132                 return TRUE;<br />
00133 #endif                          /* OPTIMIZE_JUST_STAR */<br />
00134         return DoMatch(text, p) == TRUE;<br />
00135 }<br />
00136 <br />
00137 <br />
00138 <br />
00139 #if     defined(TEST)<br />
00140 <br />
00141 /* Yes, we use gets not fgets.  Sue me. */<br />
00142 extern char *gets();<br />
00143 <br />
00144 <br />
00145 int main()<br />
00146 {<br />
00147         char p[80];<br />
00148         char text[80];<br />
00149 <br />
00150         printf("Wildmat tester.  Enter pattern, then strings to test.\n");<br />
00151         printf<br />
00152             ("A blank line gets prompts for a new pattern; a blank pattern\n");<br />
00153         printf("exits the program.\n");<br />
00154 <br />
00155         for (;;) {<br />
00156                 printf("\nEnter pattern:  ");<br />
00157                 (void) fflush(stdout);<br />
00158                 if (gets(p) == NULL || p[0] == '\0')<br />
00159                         break;<br />
00160                 for (;;) {<br />
00161                         printf("Enter text:  ");<br />
00162                         (void) fflush(stdout);<br />
00163                         if (gets(text) == NULL)<br />
00164                                 exit(0);<br />
00165                         if (text[0] == '\0')<br />
00166                                 /* Blank line; go back and get a new pattern. */<br />
00167                                 break;<br />
00168                         printf("      %s\n",<br />
00169                                wildmat(text, p) ? "YES" : "NO");<br />
00170                 }<br />
00171         }<br />
00172 <br />
00173         exit(0);<br />
00174         /* NOTREACHED */<br />
00175 }<br />
00176 #endif                          /* defined(TEST) */<br />
<br />

AnswerRe: can anyone convert this to C# Pin
leppie3-Sep-05 2:23
leppie3-Sep-05 2:23 
Questionhow to control datetimepicker control manuaaly Pin
ravimohan162-Sep-05 18:41
ravimohan162-Sep-05 18:41 
Questionexporting dataset to excel Pin
Member 22115382-Sep-05 18:28
Member 22115382-Sep-05 18:28 
Questionexporting dataset to excel Pin
Member 22115382-Sep-05 18:25
Member 22115382-Sep-05 18:25 
QuestionHow to create Graphics g? Event Fires Pin
...---...2-Sep-05 14:31
...---...2-Sep-05 14:31 
AnswerRe: How to create Graphics g? Event Fires Pin
Mohamad Al Husseiny2-Sep-05 14:41
Mohamad Al Husseiny2-Sep-05 14:41 
GeneralRe: How to create Graphics g? Event Fires Pin
...---...2-Sep-05 15:01
...---...2-Sep-05 15:01 
QuestionDataBindings for form controls. How? Pin
Lexa19832-Sep-05 14:04
Lexa19832-Sep-05 14:04 
QuestionIP help Pin
aspiringCodeMonkey2-Sep-05 12:56
aspiringCodeMonkey2-Sep-05 12:56 
AnswerRe: IP help Pin
Guffa2-Sep-05 13:21
Guffa2-Sep-05 13:21 
AnswerRe: IP help Pin
ediazc2-Sep-05 13:28
ediazc2-Sep-05 13:28 
Questionabstract class constructor? Pin
Niklas Ulvinge2-Sep-05 9:52
Niklas Ulvinge2-Sep-05 9:52 
AnswerRe: abstract class constructor? Pin
Robert Rohde2-Sep-05 10:27
Robert Rohde2-Sep-05 10:27 
QuestionRe: abstract class constructor? Pin
Guffa2-Sep-05 10:33
Guffa2-Sep-05 10:33 
AnswerRe: abstract class constructor? Pin
Niklas Ulvinge2-Sep-05 10:39
Niklas Ulvinge2-Sep-05 10:39 
AnswerRe: abstract class constructor? Pin
ediazc2-Sep-05 13:31
ediazc2-Sep-05 13:31 
GeneralRe: abstract class constructor? Pin
Niklas Ulvinge2-Sep-05 21:44
Niklas Ulvinge2-Sep-05 21:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.