harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlyd...@apache.org
Subject svn commit: r565180 - /harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/portable_libc.c
Date Sun, 12 Aug 2007 22:21:44 GMT
Author: dlydick
Date: Sun Aug 12 15:21:43 2007
New Revision: 565180

URL: http://svn.apache.org/viewvc?view=rev&rev=565180
Log:
Added portable strstr(3), strncpy(3), and isalpha(3).

Modified:
    harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/portable_libc.c

Modified: harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/portable_libc.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/portable_libc.c?view=diff&rev=565180&r1=565179&r2=565180
==============================================================================
--- harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/portable_libc.c (original)
+++ harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/portable_libc.c Sun Aug 12 15:21:43 2007
@@ -174,11 +174,16 @@
  *
  * @attention This function @b requires freeing of a result pointer
  *            with @link #HEAP_FREE_DATA() HEAP_FREE_DATA()@endlink
- *            when it is no longer needed.
+ *            when it is no longer needed.  <i>It does @b NOT return
+ *            an integer like @b stat(2) returns!</i>
  *
  *
  * Notice that this function returns an (@link #rvoid rvoid@endlink *)
- * with its result.
+ * with its result instead of an integer.  The reason for this, even
+ * though it is returned as an @link #rvoid rvoid@endlink pointer,
+ * is for that pointer to be passed to @link
+   #portable_stat_get_st_size() portable_stat_get_st_size()@endlink
+ * if desired to return information about the file.
  *
  * @param path   Path name of file, relative or absolute.
  *
@@ -703,6 +708,36 @@
 
 
 /*!
+ * @brief Portable replacement for @c @b strstr(3) library function
+ *
+ *
+ * @param s1  First null-terminated string to evaluate
+ *
+ * @param s2  Second null-terminated string to evaluate
+ *
+ *
+ * @returns pointer into @b s1 of first occurrence of @b s2 , not
+ *          including the null termination character of @b s2 in that
+ *          comparison.  Return @link #rnull rnull@endlink if not found.
+ *          If @b s2 is an empty string (of zero length), then
+ *          return @b s1 .
+ *
+ */
+rchar *portable_strstr(const rchar *s1, const rchar *s2)
+{
+    ARCH_FUNCTION_NAME(portable_strstr);
+
+    char   *s1local = (char *) s1;
+    char   *s2local = (char *) s2;
+
+    char *rc = strstr(s1local, s2local);
+
+    return((rchar *) rc);
+
+} /* END of portable_strstr() */
+
+
+/*!
  * @brief Portable replacement for @c @b strlen(3) library function
  *
  *
@@ -781,6 +816,36 @@
 } /* END of portable_strcpy() */
 
 
+/*!
+ * @brief Portable replacement for @c @b strncpy(3) library function
+ *
+ *
+ * @param[out] s1  Destination null-terminated string buffer
+ *                 into which @c @b s2 contents are copied
+ *
+ * @param[in] s2   Source [potentially] null-terminated string to
+ *                 copy into @c @b s1 buffer
+ *
+ * @param[in] n    Number of characters to copy.
+ *
+ * @returns @c @b s1
+ *
+ */
+rchar *portable_strncpy(rchar *s1, const rchar *s2, rint n)
+{
+    ARCH_FUNCTION_NAME(portable_strncpy);
+
+    char   *s1local = (char *) s1;
+    char   *s2local = (char *) s2;
+    size_t  nlocal  = (size_t) n;
+
+    char *rc = strncpy(s1local, s2local, nlocal);
+
+    return((rchar *) rc);
+
+} /* END of portable_strncpy() */
+
+
 /*@} */ /* End of grouped definitions */
 
 /*!
@@ -877,6 +942,32 @@
     return((rint) rc);
 
 } /* END of portable_isspace() */
+
+
+/*!
+ * @brief Portable replacement for @c @b isalpha(3) library function
+ *
+ *
+ * @param c  Character to evaluate
+ *
+ *
+ * @returns non-zero if @c @b c is an alphabetic character @b a
+ *          through @b z , either upper or lower case,
+ *          otherwise 0.  If @c @b c is not in the domain of
+ *          comparison, the result is undefined.
+ *
+ */
+rint portable_isalpha(rint c)
+{
+    ARCH_FUNCTION_NAME(portable_isalpha);
+
+    int clocal = (int) c;
+
+    int rc = isalpha(clocal);
+
+    return((rint) rc);
+
+} /* END of portable_isalpha() */
 
 
 /*@} */ /* End of grouped definitions */



Mime
View raw message