root/src/strcmp2.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. strcmp2

   1 /*     CalculiX - A 3-dimensional finite element program                 */
   2 /*              Copyright (C) 1998-2015 Guido Dhondt                          */
   3 
   4 /*     This program is free software; you can redistribute it and/or     */
   5 /*     modify it under the terms of the GNU General Public License as    */
   6 /*     published by the Free Software Foundation(version 2);    */
   7 /*                                                                       */
   8 
   9 /*     This program is distributed in the hope that it will be useful,   */
  10 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */ 
  11 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
  12 /*     GNU General Public License for more details.                      */
  13 
  14 /*     You should have received a copy of the GNU General Public License */
  15 /*     along with this program; if not, write to the Free Software       */
  16 /*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
  17 
  18 #include <stdlib.h>
  19 #include <math.h>
  20 #include <stdio.h>
  21 #include <string.h>
  22 #include "CalculiX.h"
  23 
  24 ITG strcmp2(const char *s1, const char *s2, ITG length)
  25 {
  26 
  27 /* comparison of the first "length" characters unless s1
  28    and/or s2 has less characters */
  29 
  30   ITG a,b,i;
  31 
  32   i=0;
  33   do {
  34     a=*s1++;
  35     b=*s2++;
  36 
  37     if(b=='\0'){
  38       a='\0';
  39       b='\0';
  40       break;
  41     }
  42     if(a=='\0'){
  43       a='\0';
  44       b='\0';
  45       break;
  46     }
  47     i++;
  48   }while((a==b)&&(i<length));
  49   return(a-b);
  50 }
  51           

/* [<][>][^][v][top][bottom][index][help] */