Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
replace sed with awk, since sed in mac is too old
Browse files Browse the repository at this point in the history
  • Loading branch information
HannahShiSFB committed Jul 28, 2020
1 parent d3c1cbf commit 1e415e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/php/bin/php_extension_doxygen_filter.awk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function sed_gensub(regexp, replacement, how, target, cmd_, ret_) { # ar
gsub(/'/, "'\"'\"'", target);
gsub(/\\\\/, "\\", regexp);

cmd_ = "printf '" target "' | sed -E 's/" regexp "/" replacement "/" tolower(how) "'";
cmd_ = "printf '" target "' | sed -nE 's/" regexp "/" replacement "/" tolower(how) "p'";
if (cmd_ | getline ret_ != 1) {
close(cmd_);
error = "ERROR: running command: " cmd_ ", ret_: " ret_;
Expand Down Expand Up @@ -85,7 +85,7 @@ inDocComment==1 && $0 ~ classLineRegex {
}

# end of class document
inDocComment==1 && /\*\// && classDocComment == "" {
inDocComment==1 && /\*\// && className && classDocComment == "" {
classDocComment = docComment;
docComment = "";
}
Expand Down
3 changes: 2 additions & 1 deletion src/php/bin/php_extension_to_php_doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ COMMAND="${1:-}"
# parse class and methods
for FILENAME in call_credentials.c call.c channel.c channel_credentials.c \
server_credentials.c server.c timeval.c ; do
CLASS_NAME=$(sed -E 's/(^|_)(\w)/\U\2/g' <<< "${FILENAME%.*}")
CLASS_NAME=$(awk -F _ '{for(i=1; i<=NF; i++) printf "%s", toupper(substr($i,1,1)) substr($i, 2);}' \
<<< "${FILENAME%.*}")
if [[ "$COMMAND" == "generate" ]]; then
echo Generating lib/Grpc/$CLASS_NAME.php ...
awk -f php_extension_doxygen_filter.awk ../ext/grpc/$FILENAME \
Expand Down

0 comments on commit 1e415e2

Please sign in to comment.