Permalink
Browse files

Add Parrot_str_foldcase to the string subsystem API. Expose this thro…

…ugh a new foldcase op.
  • Loading branch information...
Whiteknight committed Jun 9, 2012
1 parent e0dd1ad commit 1ebef0efaa9cdbbb377512ca09da6d369d2d5a55
Showing with 1,009 additions and 919 deletions.
  1. +2 −0 include/parrot/oplib/core_ops.h
  2. +231 −229 include/parrot/oplib/ops.h
  3. +231 −229 include/parrot/opsenum.h
  4. +8 −0 include/parrot/string_funcs.h
  5. +499 −461 src/ops/core_ops.c
  6. +10 −0 src/ops/string.ops
  7. +28 −0 src/string/api.c
@@ -917,6 +917,8 @@ op_lib_t *Parrot_DynOp_core_4_4_0(PARROT_INTERP, long init);
opcode_t * Parrot_downcase_s_sc(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_titlecase_s_s(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_titlecase_s_sc(opcode_t *, PARROT_INTERP);
+ opcode_t * Parrot_foldcase_s_s(opcode_t *, PARROT_INTERP);
+ opcode_t * Parrot_foldcase_s_sc(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_join_s_s_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_join_s_sc_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_split_p_s_s(opcode_t *, PARROT_INTERP);
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -180,6 +180,12 @@ PARROT_EXPORT
void Parrot_str_finish(PARROT_INTERP)
__attribute__nonnull__(1);
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PARROT_MALLOC
+STRING * Parrot_str_foldcase(PARROT_INTERP, ARGIN_NULLOK(const STRING *s))
+ __attribute__nonnull__(1);
+
PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
STRING * Parrot_str_format_data(PARROT_INTERP,
@@ -556,6 +562,8 @@ STRING * Parrot_str_new_from_cstring(PARROT_INTERP,
, PARROT_ASSERT_ARG(search))
#define ASSERT_ARGS_Parrot_str_finish __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_Parrot_str_foldcase __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_str_format_data __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(format))
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -435,6 +435,16 @@ inline op titlecase(out STR, in STR) {
$1 = Parrot_str_titlecase(interp, $2);
}
+=item B<foldcase>(out STR, in STR)
+
+Foldcase $2 and put the result in $1
+
+=cut
+
+inline op foldcase(out STR, in STR) {
+ $1 = Parrot_str_foldcase(interp, $2);
+}
+
=item B<join>(out STR, in STR, invar PMC)
View
@@ -2903,6 +2903,34 @@ Parrot_str_titlecase(PARROT_INTERP, ARGIN_NULLOK(const STRING *s))
}
}
+/*
+
+=item C<STRING * Parrot_str_foldcase(PARROT_INTERP, const STRING *s)>
+
+Returns a copy of the specified Parrot string case-folded. Non caseable
+characters are left unchanged. The encoding of the string may be modified.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PARROT_MALLOC
+STRING *
+Parrot_str_foldcase(PARROT_INTERP, ARGIN_NULLOK(const STRING *s))
+{
+ ASSERT_ARGS(Parrot_str_foldcase)
+
+ if (STRING_IS_NULL(s))
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
+ "Can't foldcase NULL string");
+ else {
+ STRING * const res = STRING_foldcase(interp, s);
+ res->hashval = 0;
+ return res;
+ }
+}
/*

0 comments on commit 1ebef0e

Please sign in to comment.