"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "matching_cgo.go" between
sift-0.8.0.tar.gz and sift-0.9.0.tar.gz

About: sift is an alternative to grep that aims for both speed and flexibility (written in Go).

matching_cgo.go  (sift-0.8.0):matching_cgo.go  (sift-0.9.0)
skipping to change at line 18 skipping to change at line 18
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
package main package main
/* func countNewlines(input []byte, length int) int
#cgo CFLAGS: -std=gnu99 -O2 -funroll-loops func bytesToLower(input []byte, output []byte, length int)
#include <stddef.h>
inline int count_newlines(const unsigned char *buf, size_t n) {
int count = 0;
int base;
int dist = n / 4;
for (int i = 0; i < dist; i++) {
base = i * 4;
if (buf[base] == 0x0a) {
count++;
}
if (buf[base+1] == 0x0a) {
count++;
}
if (buf[base+2] == 0x0a) {
count++;
}
if (buf[base+3] == 0x0a) {
count++;
}
}
for (int i = (n / 4) * 4; i < n; i++) {
if (buf[i] == 0x0a) {
count += 1;
}
}
return count;
}
inline void bytes_to_lower(const unsigned char *buf, unsigned char *out, size_t
n) {
int base;
int dist = n / 4;
for (int i = 0; i < dist; i++) {
base = i * 4;
out[base] = (buf[base] - 65U < 26) ? buf[base] + 32 : buf[base];
out[base+1] = (buf[base+1] - 65U < 26) ? buf[base+1] + 32 : buf[b
ase+1];
out[base+2] = (buf[base+2] - 65U < 26) ? buf[base+2] + 32 : buf[b
ase+2];
out[base+3] = (buf[base+3] - 65U < 26) ? buf[base+3] + 32 : buf[b
ase+3];
}
for (int i = (n / 4) * 4; i < n; i++) {
out[i] = (buf[i] - 65U < 26) ? buf[i] + 32 : buf[i];
}
}
*/
import "C"
func countNewlines(input []byte, length int) int {
return int(C.count_newlines((*C.uchar)(&input[0]), C.size_t(length)))
}
func bytesToLower(input []byte, output []byte, length int) {
C.bytes_to_lower((*C.uchar)(&input[0]), (*C.uchar)(&output[0]), C.size_t(
length))
}
 End of changes. 1 change blocks. 
0 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)