! * \brief sarrayAppendRange() * * \param[in] sa1 to be added to * \param[in] sa2 append specified range of strings in sa2 to sa1 * \param[in] start index of first string of sa2 to append * \param[in] end index of last string of sa2 to append; -1 to end of array * \return 0 if OK, 1 on error * * * Notes: * (1) Copies of the strings in sarray2 are added to sar
| 918 | * </pre> |
| 919 | */ |
| 920 | l_int32 |
| 921 | sarrayAppendRange(SARRAY *sa1, |
| 922 | SARRAY *sa2, |
| 923 | l_int32 start, |
| 924 | l_int32 end) |
| 925 | { |
| 926 | char *str; |
| 927 | l_int32 n, i; |
| 928 | |
| 929 | PROCNAME("sarrayAppendRange"); |
| 930 | |
| 931 | if (!sa1) |
| 932 | return ERROR_INT("sa1 not defined", procName, 1); |
| 933 | if (!sa2) |
| 934 | return ERROR_INT("sa2 not defined", procName, 1); |
| 935 | |
| 936 | if (start < 0) |
| 937 | start = 0; |
| 938 | n = sarrayGetCount(sa2); |
| 939 | if (end < 0 || end >= n) |
| 940 | end = n - 1; |
| 941 | if (start > end) |
| 942 | return ERROR_INT("start > end", procName, 1); |
| 943 | |
| 944 | for (i = start; i <= end; i++) { |
| 945 | str = sarrayGetString(sa2, i, L_NOCOPY); |
| 946 | sarrayAddString(sa1, str, L_COPY); |
| 947 | } |
| 948 | |
| 949 | return 0; |
| 950 | } |
| 951 | |
| 952 | |
| 953 | /*----------------------------------------------------------------------* |
no test coverage detected