From owner-freebsd-questions Fri Aug 22 15:20:44 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id PAA06979 for questions-outgoing; Fri, 22 Aug 1997 15:20:44 -0700 (PDT) Received: from dg-rtp.dg.com (dg-rtp.rtp.dg.com [128.222.1.2]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id PAA06968 for ; Fri, 22 Aug 1997 15:20:36 -0700 (PDT) Received: by dg-rtp.dg.com (5.4R3.10/dg-rtp-v02) id AA29774; Fri, 22 Aug 1997 18:20:02 -0400 Received: from ponds by dg-rtp.dg.com.rtp.dg.com; Fri, 22 Aug 1997 18:20 EDT Received: from lakes.dignus.com (lakes [10.0.0.3]) by ponds.dignus.com (8.8.5/8.7.3) with ESMTP id QAA11555; Fri, 22 Aug 1997 16:05:39 -0400 (EDT) Received: (from rivers@localhost) by lakes.dignus.com (8.8.5/8.6.9) id PAA03915; Fri, 22 Aug 1997 15:58:38 -0400 (EDT) Date: Fri, 22 Aug 1997 15:58:38 -0400 (EDT) From: Thomas David Rivers Message-Id: <199708221958.PAA03915@lakes.dignus.com> To: domenic@aix.can.ibm.com, ponds!FreeBSD.ORG!questions Subject: Re: coding... Content-Type: text Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > hi folks, > I know....there is no gcvt and basename functions available... > I am trying to port code over to FreeBSD and I cant find equivalents. > any takers ? > thanks, > domenic > -- For a 'dumb' gcvt() (you'd really want to check string sizes, etc..) you can use sprintf(), e.g. gcvt(d, n, str) becomes: sprintf(str,"%f", d); [you can get really fancy with the format specification and handle the number of digits, etc... I'll leave that up to the reader...] Here's a basename() function - this returns a pointer within the original string - so don't modify the result pointer... char * basename(string) char *string; { char *start_of_basename; start_of_basename = string + (strlen(string) - 1); while(start_of_basename != string) { if(*start_of_basename == '/') { break; } start_of_basename --; } if(start_of_basename == string) { /* Didn't find anything */ return start_of_basename; } else { /* Bump past the '/' and return a pointer */ /* to the basename. */ if(*start_of_basename == '/') start_of_basename++; return start_of_basename; } } - Dave Rivers -