Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. // This checks if the char is either a number or a letter
  2. int checkIfChar(char c) {
  3. if (c >= 'A' && c <= 'Z') {
  4. return 1;
  5. }
  6. if (c >= 'a' && c <= 'z') {
  7. return 1;
  8. }
  9. if (c >= '0' && c <= '9') {
  10. return 1;
  11. }
  12. return 0;
  13. }
  14.  
  15. // This handles the processing of the plus case
  16. int plusCase(char *partial_line, char *pattern) {
  17. int count = 0;
  18. // Loop while we have another pattern instance
  19. while(*partial_line == *(pattern-1)) {
  20. partial_line++;
  21. count++;
  22. }
  23. return count;
  24. }
  25.  
  26. // This handles the processing of the question mark case
  27. int questionMarkCase(char *partial_line, char *pattern) {
  28. // This checks if we still
  29. if(*(partial_line) == *(pattern)) {
  30. return 1;
  31. }
  32. else {
  33. return 2;
  34. }
  35. return 0; // No question mark
  36. }
  37.  
  38. // This handles the processing of the backslash case
  39. int backslashCase(char *partial_line, char *pattern) {
  40. // skips whatever we are escaping
  41. if(*(partial_line) == *(pattern+1)) {
  42. return 1;
  43. }
  44. return 0; // no backslash
  45. }
  46.  
  47. // This handles the processing of the fullstop case
  48. int fullStopCase(char *partial_line, char *pattern) {
  49. int checker = 0;
  50. // checks if it is actually a char se we can skip over it
  51. checker = checkIfChar(*partial_line);
  52. if(checker){
  53. return 1;
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement