Changeset be5aa09 for util.c


Ignore:
Timestamp:
Feb 23, 2007, 3:12:49 PM (18 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
59916e8
Parents:
1cc95709
Message:
Fixing a bug reported over zephyr in which narrowing would permanently
break replies due to in-place string manipulation.

owl_util_baseclass now returns a new string, which must be freed by
the caller.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r7a20e4c rbe5aa09  
    739739/* Return the base class or instance from a zephyr class, by removing
    740740   leading `un' or trailing `.d'.
    741    Modified ``class'' in place, and does not allocate memory.
     741   The caller is responsible for freeing the allocated string.
    742742*/
    743743char * owl_util_baseclass(char * class)
    744744{
     745  char * newClass;
    745746  char * end;
    746   while(!strncmp(class, "un", 2)) {
    747     class += 2;
    748   }
    749   end = class + strlen(class) - 1;
     747  newClass = owl_strdup(class);
     748  while(!strncmp(newClass, "un", 2)) {
     749    newClass += 2;
     750  }
     751  end = newClass + strlen(newClass) - 1;
    750752  while(*end == 'd' && *(end-1) == '.') {
    751753    end -= 2;
    752754  }
    753755  *(end + 1) = 0;
    754   return class;
     756  return newClass;
    755757}
    756758
Note: See TracChangeset for help on using the changeset viewer.